Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding example to OptionsMerging #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions OptionsMerging.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,23 @@ fluid.merge(policy, target, source-1, ... source-n);
```

where `policy` is the _merge policy object_ (may be empty), `target` is the object to (destructively) be the target of the merge operation, and `source-1` through `source-n` are a list of a number of "source" options structure from which the merge is to be performed.

## Examples ##
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sgithens, thanks for adding this example! The arrayConcatPolicy is not yet explained in the table of policy values above. Would you be willing to add a row to the table with a brief description?


Below is a transcript of a Node REPL session showing a simple example where we have 2 documents to merge, and we wish for the common array in both of them to contain the concatenated values from both in the final document.

```bash
> var one = { cool: "wow", mylist: [1, 1] };
> var two = { neat: "awesum", mylist: [2, 3, 5, 8]};
> fluid.merge({mylist: fluid.arrayConcatPolicy},{},one,two);
{ neat: 'awesum',
mylist:
[ 1,
1,
2,
3,
5,
8 ],
cool: 'wow' }
>
```