0
MongoDB 3.2には次のコレクションがあります。2つの配列で照合が必要なMongoクエリ
db.collection.insert(
{
permissions: [
{field: 'name', canEdit: true},
{field: 'age', canEdit: false}
// ... lots of other fields
],
inputs: [
{field: 'name', edited: false},
{field: 'age', edited: false}
// ... lots of other fields
]
}
);
両方canEdit = true
とedited = true
と少なくともつのフィールド持っているすべての文書を返しますMongoDBのクエリを記述する方法はありますか?擬似的に表現さ
上記の質問:
find document D where exists
P in D.permissions
I in D.inputs
P.field = I.field and P.canEdit = true and I.edited = true
のような配列です。提案しているクエリは、フィールドから独立してcanEditと編集されたフラグを探します。私がチェックする必要があるのは、 'P.field = I.fieldとP.canEdit = trueとI.edited = true'です。 –