Relative Content

Tag Archive for mongodbaggregate

How To Query Unknown Key’s Value Documents With Nested Structure in MongoDB?

I have a problem with querying with MongoDB, here’s the data structure in MongoDB: { “_id”: “aaaaa”, “groups”: [ { “name”: “group0”, “props”: { “unknown1”: “value1”, “unknown2”: “value2”, “unknown3”: “value3” } }, { “name”: “group1”, “props”: { “unknown4”: “value4”, “unknown5”: “value5”, “unknown6”: “value6” } } ] } I want to query documents whose nested fields […]

mongodb query $match if tenary to field

i have a query in mongodb, i want to get from collection by specific field the field is “private.group” and its boolean.
i want the $match will be dynamic to pass is as varible (pass is true or false) and then make this query work as private group or public group.
how can i make this if tenary work in $match?
i can pass parameter to the function but its not work with if tenary
i mean this line of group.private