MongoDB / mongoose queries and the $ in operator

Question about MongoDB / mongoose queries using $ in http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24in

If I make a request in which both the target and the $ in fields have multiple values, is there a way to find out which // in elements in the field element were matched in the returned argument?

For example, if I have a bunch of documents like this

doc1 = { name : Abe, children : [Betty, Claire, Donald, Eamon] }

and I set the request

Model.find( { children : { $in : [Ann, Betty, Clive] } })

if I get the result of doc1 above, is there any way I can know (without repeating through arrays manually) which target element and which $ element in the element match? so in the above case, how could I access that doc1 was selected because it matched Betty? Thanks in advance!

+3
source share
1 answer

You must manually check the mongoose document.

+2
source

All Articles