Updating merge docs

This commit is contained in:
Mike Farah 2022-05-24 16:16:58 +10:00
parent fbe49c3700
commit 451d8643ee
2 changed files with 12 additions and 0 deletions

View File

@ -28,3 +28,9 @@ Note the use of `eval-all` to ensure all documents are loaded into memory.
```bash
yq eval-all '. as $item ireduce ({}; . * $item )' *.yml
```
# Merging complex arrays together by a key field
By default - `yq` merge is naive. It merges maps when they match the key name, and arrays are merged either by appending them together, or merging the entries by their position in the array.
For more complex array merging (e.g. merging items that match on a certain key) please see the example [here](https://mikefarah.gitbook.io/yq/operators/multiply-merge#merge-arrays-of-objects-together-matching-on-a-key)

View File

@ -29,6 +29,12 @@ Note the use of `eval-all` to ensure all documents are loaded into memory.
yq eval-all '. as $item ireduce ({}; . * $item )' *.yml
```
# Merging complex arrays together by a key field
By default - `yq` merge is naive. It merges maps when they match the key name, and arrays are merged either by appending them together, or merging the entries by their position in the array.
For more complex array merging (e.g. merging items that match on a certain key) please see the example [here](https://mikefarah.gitbook.io/yq/operators/multiply-merge#merge-arrays-of-objects-together-matching-on-a-key)
{% hint style="warning" %}
Note that versions prior to 4.18 require the 'eval/e' command to be specified.