node.js - Difference between two arrays of Mongo Document _ids -


essentially, have 2 arrays of _ids mongodb i'm trying compare/get differences of.

array 1 comes directly document.find() call. array 2 comes document.aggregate call, of _.pluck _id both of them.

array 1 might [ 1 , 57, 58, 100 ] example.
array 2 might [ 1 , 2, 3, 4, 55, 100 ] example.

i want find difference , return , [ 57, 58 ].

to i've been using lodash library. , i've tried following 2 methods:

_.difference(array1, array2) 

and

_.filter(array1, function(obj){ return !_.findwhere(array2, obj); }); 

but both don't seem work. i'd love if possible.

ignore. turns out filter code worked. db error.

_.filter(array1, function(obj){ return !_.findwhere(array2, obj); }); 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -