Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MongoDB-Shell脚本-$ref中使用的$_Mongodb_Robo3t - Fatal编程技术网

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(…)]})