mongo-diff
Component to perform a diff between two objects expressed as MongoDB operations.
Example
var diff = ; // diff two arrays using set strategy /*[ ['pull', 'a'], ['push', 'a']]*/
Strategies
auto
// [['unset', 1]] // [['inc', 4]]
val(a, b)
diff// [['set', 'b']] diff// [['unset', 1]]
Expresses differences as $set
or $unset
.
inc(a, b, opts)
diff// [['inc', 1], ['inc', 1], ['inc', 1]]
Options:
interval
increment interval. Ifnull
the interval defaults to the difference between the numbers (null
)
Expresses differences between numbers in terms of $inc
operations.
ordered_set(a, b)
diff;// [['push', 'a']]
Expresses the difference between arrays as a series of $pull
/ $push
operations. Useful to match differences on arrays that are used with
the $addToSet
MongoDB operation.
TODO
- More strategies
- Ordered set indexOf should use deep matching for object/array support