0

集合中的一个属性引用了另一个集合的文档,所以它看起来像这样

collection {
    "reffedDoc": {
         "$ref": "myClass",
         "$id": ObjectId("4e171cade3a9f23359e98206") 
      },
    ....
}

那么,如何在我的字段中选择 refedDoc.$id?我可以在不获取整个子文档的情况下获取这个吗?我试过 refedDoc.$id

db.collection.find({}, {"reffedDoc.$id"});

我收到以下错误

Positional operator does not match the query specifier
4

0 回答 0