I have some collections such us this:
[{
"_id": ObjectId("604f3ae3194f2135b0ade569"),
"parameters": [
{
"_id": ObjectId("602b7455f4b4bf5b41662ec1"),
"name": "Purpose",
"options": [
{
"id": ObjectId("602b764ff4b4bf5b41662ec2"),
"name": "debug",
"sel": false
},
{
"id": ObjectId("602b767df4b4bf5b41662ec3"),
"name": "performance",
"sel": false
},
{
"id": ObjectId("602b764ff4b4bf5b41662ec4"),
"name": "security",
"sel": false
},
{
"id": ObjectId("602b767df4b4bf5b41662ec5"),
"name": "Not Applicable",
"sel": false
}
],
"type": "multiple"
},
{
"_id": ObjectId("602b79d35d4a1333b8b6e5ba"),
"name": "Organization",
"options": [
{
"id": ObjectId("602b79d353c89933b8238325"),
"name": "SW",
"sel": false
},
{
"id": ObjectId("602b79d353c89933b8238326"),
"name": "HW",
"sel": false
}
],
"type": "multiple"
}
]
}]
The parameters are most 30.
I need to implements in mongo a "filter" collections.
If I filter one or more parameters._id, mongo return:
- collection _id that have match
options.selofthis parameters._id - collection _id that have all
options.selequal tofalseofthis parameters._id - non return collection _id if
parameters._idhas set upoptions.name:"Not Applicable"at valueoptions.sel:true
For example, if I match parameters._id:ObjectId("602b7455f4b4bf5b41662ec1") and this parameters.options.id:ObjectId("602b764ff4b4bf5b41662ec2"), I expect:
- not collection _id that has, for
parameters._id:ObjectId("602b7455f4b4bf5b41662ec1"), the specificparameters.options.id: ObjectId("602b767df4b4bf5b41662ec5")at valueoptions.sel:true - all collection _id that match with query
- all collection _id that has, for
parameters._id:ObjectId("602b7455f4b4bf5b41662ec1"), all specificparameters.options.sel:false
Next I need to make this rule for more parameters.
I have think to implements three aggregation for every rule... Do you have suggestion?