私がこのように質問するとき:
collection.find({ "position": { $in: [ 1, 2 ] } }).toArray()....
$and
またはを使用すると、正しい結果が得られます$or
。たとえば、次のようになります。
collection.find({ $or: [ { "position": 1 }, { "position": 2 } ] }).toArray()...
私はいつも空の結果を得る
編集:コンソールでクエリを実行しようとすると、次のようになります。
> 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
これから、私は印象を受けます、私のコードは大丈夫です、そして問題は他の場所にあります...