更新时间:2023-02-14 11:45:01
您可以使用$elemMatch
查询运算符.没有直接查询运算符可以解决您的情况.
You can use $elemMatch
query operator. There is no direct query operator to address your case.
db.collname.find( { "patient.drug": { $not: { $elemMatch: { openfda: {$exists:false} } } } } )
"$elemMatch" + "$exists:false"
这部分包括patient.drug
数组没有至少一个openfda
嵌入式文档的所有文档.
This part includes all the documents where patient.drug
array don't have at least one openfda
embedded document.
$not
此部分将保留所有不在"$elemMatch" + "$exists:false"
中的文档.
This part will keep the all the documents which are not in "$elemMatch" + "$exists:false"
.
所有具有所有drugs
数组的文档都具有openfda
嵌入式文档.
These are all the documents that has its all drugs
array have openfda
embedded doc.