I am using this mongo extension in Yii2.
I have 2 collections named ServiceProvider and Parents. In ServiceProvider there is subdocument (PostCommentIDs) containing IDs of parents.
Another collection Parents contains all parent information.
I wanted to join the 2 collection. I have achieved it through the following mongo query.
But using the above extension how do I write this query in Yii2.
db.ServiceProvider.aggregate([
{
$unwind: "$PostCommentIDs"
},
{
$lookup:
{
from: "Parents",
localField: "PostCommentIDs",
foreignField: "ID",
as: "ParentDetails"
}
},
{
$match: { "ParentDetails": { $ne: [] } }
}
])
Please help. Thanks!