Folks,
I am able to search MongoDB Collection for any value in an array:
var searchArray = ['foo','bar'];
with the following query:
var query = {
widgets: {
'$in': searchArray
}
};
The result will be Objects that have widgets that match either foo or bar.
What should the MongoDB query look like to search for widgets that are foo and bar and nothing else. In other words, only widgets that have foo and bar in them will be returned. If there is a [foo,bar,baz`] it will be skipped. If there is only a ['foo'], it will be skipped as well.
Thanks!
UPDATE: This seems to work:
var query = {
widgets: {
'$all': searchArray
}
};
Anything wrong with using $all ?