I have two collections in the following format -
collection1:
{
"_id": "col1id1",
"name": "col1doc1",
"properties": [ "<_id1>", "<_id2>", "<_id3>"]
}
collection2:
{
"_id": "<_id1>",
"name": "doc1",
"boolean_field": false
},
{
"_id": "<_id2>",
"name": "doc2",
"boolean_field": true
},
{
"_id": "<_id3>",
"name": "doc3",
"boolean_field" : false
}
The desired output is:
{
"_id": "col1id1",
"name": "col1doc1",
"property_names": ["doc1", "doc3"]
}
The field properties
of document in collection1 has three IDs of documents in collection2 but the output after join operation should contain only those which have the boolean_field
value as false
.
How can I perform this filter with a join operation in MongoDB?