Hi, I’ve done some research on the problem I’m working on, specifically reading over the docs for $all, $in, $elemMatch etc. but I still don’t understand how to write a query to do the following:
User 1 has groups: [A, B, C]
User 2 has groups: [C, D, E]
Ticket 1 groups required: [A, B] <— matches User 1. Does not match User 2.
Ticket 2 groups required: [B, C] <— matches User 1. Does not match User 2.
Ticket 3 groups required: [C, D] <— does not match User 1, because it contains one required group (D) not in the user groups. Matches User 2.
The “groups” on the ticket are required for a user to take a ticket. If there are any groups in the group array on the ticket not in the user’s group list, the user can’t take the ticket. In other words, the required groups on a ticket have to be equal to a user’s group list, or a subset of a user’s group list for the ticket to be matched/returned.
If it matters/makes a difference, this is being added as a $match stage of an existing aggregation query.
Is this possible? Can you please offer some pointers for how to go about this?
Thanks for any help you can offer