When I query like this :
collection.find({ "position": { $in: [ 1, 2 ] } }).toArray()....
I get the right result, when I use $and
or $or
, for example:
collection.find({ $or: [ { "position": 1 }, { "position": 2 } ] }).toArray()...
I always get the empty result
EDIT: when trying to query in console I get:
> db.foo.find({"position":{$in:[1,2]}})
{ "name" : "Jon Doe", "position" : 1, "arrival" : "8:00", "_id" :ObjectId("512e2ed286d19b9e4d000001") }
{ "name" : "Jack Smith", "position" : 2, "arrival" : "10:00", "_id" : ObjectId("512e2ed286d19b9e4d000007") }
db.foo.find( { $or : [{"position":1},{"position":2}]} )
//nothing here
From this, I get the impression, my code is OK and the problem is elsewhere...