I used to have two filters to get data from my mongoDB, however I do not think that it is efficient considering it has to do two queries to the DB.
filter = bson.M{
"$and": []bson.M{
{"partnerA.id": id},
{"unlocked": false},
{"deletedAt": nil},
},
}
filter = bson.M{
"$and": []bson.M{
{"partnerB.id": id},
{"unlocked": false},
{"deletedAt": nil},
},
}
I tried to combine them using this solution I found and came out with this filter:
filter := bson.M{
"$and": []bson.M{
{"partnerA.id": id},
{"unlocked": false},
{"deletedAt": nil},
},
"$or": bson.A{
bson.M{"$and": []bson.M{
{"partnerB.id": id},
{"unlocked": false},
{"deletedAt": nil},
}},
},
}
However it does not work and I can't find the solution for it. Does anyone see the problem for this?
Thank you.