Hello,
I take over a code in below:
"$lookup": bson.M{
"from": "place",
"let": bson.M{"resource_id": "$resource_id"},
"pipeline": []bson.M{
bson.M{
"$match": bson.M{
"$expr": bson.M{
"$and": []bson.M{
bson.M{"$eq": []string{"$_id", "$$resource_id"}},
bson.M{"$eq": []string{"$status", "active"}},
},
},
},
},
},
"as": "place",
},
},
I am quite confusing about the sequence of $match --> $expr --> $and --> $eq
I think the correct one should be: $match --> $and --> $expr --> $eq
. If both of the two sequence are correct, what’s the difference on the result?
in the mean while, I want to use json to represent the stage above, so here is my code:
{
"$lookup": {
"from": "place",
"let" : {"resource_id" : "$resource_id"},
"pipeline" : [
{
"$match" : {
"$and" :[
{
"$expr" : {
"$eq": ["$_id" , "$$resource_id"]
}
},
{
"$expr" : {
"$eq": ["$status", "active"]
}
}
]
}
}
],
"as" : "place"
}
}
is it correct?
thanks,
James