我正在使用投影运算符$中的任何随机键,它仍在工作并提供记录。 GHGHGHGH.GHGHGHGHGHGH该密钥在mongodb的文档(如下所述)中不存在。
{
"_id" : ObjectId("5cb7043715a7196aff239ee2"),
"AOE" : [
{ "areaOfExpertise" : "aoe1", "subAOE" : [ "s1", "s2", "s3", "s4" ] }
,
{ "areaOfExpertise" : "aoe2", "subAOE" : [ "s11", "s12", "s13", "s14" ] }
],
"poolName" : "newpool",
"__v" : 0
}
正确的查询:---
findOne(
{ poolName: "newpool", "AOE.areaOfExpertise": "aoe1" }
, {_id: 0, 'AOE.$': 1})
如果我使用下面提到的查询(错误查询),它仍然会给出输出,不会抛出错误。
错误查询:---
findOne({ poolName: "newpool", "AOE.areaOfExpertise": "aoe1" }
, {_id: 0, 'AOE.GHGHGHGH.GHGHGHGHGHGH.$.subAOE': 1})