0
样本文档像下面检查,并返回包含它的
{
"_id" : ObjectId("58f5ae159dfbbf2c98041952"),
"patient" : {
"drug" : [
{
"drugstartdate" : "20151007",
"actiondrug" : "1",
"openfda": {
//some fields here
}
},
{
//details of one more drug that may or may not contain openfda field
}
]
},
{//Second report
},.....
文件
如何返回包含“openfda”子文件(报告) - 药物阵列中所有药物元素的文件?尝试了以下内容:
db.getCollection('collname').find({"patient.drug":
{$elemMatch:{"openfda":
{$exists:true}
}
}
})
$ elemMatch将回到那里ATLEAST一个药含有 “openfda” 字段中的所有报告。还尝试过:
db.getCollection('BigFDAData_05_06').find({"patient.drug":
{$all:["openfda"]}})
但是,上述内容没有任何回报。什么是实现这一目标的正确途径?
这是一个'$不是'需要!谢谢,@Veeram。 – ABB