Reputation: 2246
I am having an issue crafting a good query for what I need. I need two separate OR clauses for my query. to clarify, I'll give an example:
{ $or : [ { key1 : valueA }, { key2 : valueB } ], $or: [{ key3 : valueC },
{ key4 : valueD }]}
This query just does an OR operation on all of the keys and values. What I need is two separate OR queries. So what I need is (not in code):
(key1 : valueA OR key2 : valueB) and (key3 : valueC OR key4 : valueD)
Does anyone have an efficient and Mongo-ish way to complete such query?
Upvotes: 0
Views: 110
Reputation: 6712
Mongo does have $and capability.
http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24and
Upvotes: 1