How to I ensure that all items in an $in clause return a match in MongoDB? -
i working set of documents this:
{ name : "bcc 204", //etc } i have list of names want map db entries.
for example:
var names = [ "bcc 204", "stew 101", "smth 123" ] and want make query
db.labs.find( { name : { $in: names } } ); but $in operator not ensure each item in names array matches result in db.
(more info, names unique)
you can't in query. $in check document matches @ least 1 entry in array given, it's not going consider entire result set. concern you'll need manage in application. given list of inputs, need retrieve results check given_names - results.map(:name) empty.
to put more simply, queries match documents, compose result set - don't match result set.
Comments
Post a Comment