Skip to content

Commit

Permalink
Updating merge docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mikefarah committed May 24, 2022
1 parent fbe49c3 commit 451d864
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/yqlib/doc/operators/headers/multiply-merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

6 changes: 6 additions & 0 deletions pkg/yqlib/doc/operators/multiply-merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. 

Expand Down

0 comments on commit 451d864

Please sign in to comment.