Skip to content

Comments

Adding option tomatch array elements when comparing#18

Open
peizguo wants to merge 4 commits intoa2design-inc:masterfrom
peizguo:array_comparison
Open

Adding option tomatch array elements when comparing#18
peizguo wants to merge 4 commits intoa2design-inc:masterfrom
peizguo:array_comparison

Conversation

@peizguo
Copy link

@peizguo peizguo commented Feb 22, 2016

When comparing the following two arrays:
array1 = [{id: 123, color: 'green'}, {id: 456, color: 'red'}]
array2 = [{id: 123, color: 'green'}, {id: 789, color: 'blue'}]
Instead of a result {:update => {1: {:update => {id: 789, color: 'blue'}}}}
What you get by passing the :id as the matching key
{:remove => {1: {id: 456, color: 'red'}}, :append => {1: {id: 789, color: 'blue'}}}

Peizong Guo added 4 commits February 22, 2016 11:24
When elements in two array match by the matching_key, it will be treated as update
Compatible with previous arguments
Add document for array comparison with matching key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant