For instance:
collectionA:
doc 1
{
_id:001,
name:'Eliza',
day:'Wednesday'
}
doc 2
{
_id:002,
name:'John',
day:'Thursday'
}
This example continues.. collectionB:
doc1
{
_id:201,
classNames:{
Eliza:{
student:true
},
John:{
student:false
}
}
},
{
_id:202,
classNames:{
Eliza:{
student:false
},
John:{
student:true
}
}
}
In the given scenario, performing a lookup is necessary. The challenge lies in having the local field as the value of the name field and the foreign field being the key of collection B. Additionally, obtaining the count is required.
Different aggregation techniques have been attempted without success thus far.