I am using mongoDB database. in which I have collection in below format.
{ name : name1 , area: a , country : c}
{ name : name2 , area: b , country : c}
{ name : name3 , area: a1 , country : c1}
{ name : name4 , area: b1 , country : c1}
i want query like
select * from coll where (country =c and area =a) or (country = c1 and area = b1)
in mongodb query.
I have read many document but not found suitable answer.
So if any one knows please repl开发者_Python百科y.
Thanks
By default, all elements in a mongodb query use the and
operator. You can specify an or
operator using the { "$or": [ ... ] }
construct, as described in the documentation.
Your query will be :
{ "$or": [ { "country": "c", "area": "a" }, { "country": "c1", "area": "b1" } ] }
精彩评论