Hey I have groups with 2 properties which together create 1 unique ID. We can’t have the same a and b repeated.
_id: {{ a: 1, b: 3 }}
_id: {{ a: 2, b: 2 }}
_id: {{ a: 1, b: 2 }}
I have two problems
- The order of the properties shouldn’t be important. {a:1, b:2} === {b:2,a:1}
- I need to search for multiple object in the same query as if I were using the $in operator for 1 property IDs.
Something like this
db.inventory.find( { $in: [ {_id: {a: 1, b: 1}, {a: 1,b: 1} }] } )
What is the best approach to accomplish this?