MongoDB-Shell脚本-$ref中使用的$
如何在MongoDB-Shell脚本-$ref中使用的$,mongodb,robo3t,Mongodb,Robo3t,如何在$ref中正确使用$in cursor = db.MyCollection.find({ "player": { "$ref": "Contact", "$id": { $in: [ObjectId("556d901118bfd4901e2a3833"), ObjectId("556d901118bfd4901e2a3833")] } ^ it executes successfully, but does not find anyt
$ref
中正确使用$in
cursor = db.MyCollection.find({
"player": {
"$ref": "Contact",
"$id": {
$in: [ObjectId("556d901118bfd4901e2a3833"), ObjectId("556d901118bfd4901e2a3833")]
} ^ it executes successfully, but does not find anything
}
})
甚至可以在
$ref
中使用$in
吗?不要使用DBRef。这是个坏消息。手动构造引用。或者更好的是,在您可以的地方“嵌入”。您不能只执行db.MyCollection.find({'player.$id':{$in:[ObjectId(…),ObjectId(…),ObjectId(…)]})
?