Select leadId count on two collection in Mongo DB
Collection 1 : leads
{
leadId:"abc123",
status:"OPENED",
stage:"start",
crossSell:
{
cc:
{
consent:true,
shown:[{first:true}]
}
}
}
Collection 2 : pdata
{
activeLeadId:"abc123",
status:"OPENED",
details:
[
{
rating:10
},
{
rating:9
}
]
}
Question : Find leadId count from leads collection join with pdata collection based on below conditions
- leads.leadId = pdata.activeleadId and
- leads.status = "OPENED" and
- leads.crossSell.cc.consent = true and
- leads.crossSell.cc.shown[0].first = true and
- pdata.details.rating >= 5
statusshould be"OPENED"? Which or how manyratings in thedetailsarray need to have a value of5or higher?