Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mongodb ORing和ANDing查询_Mongodb_Mongodb Scala - Fatal编程技术网

mongodb ORing和ANDing查询

mongodb ORing和ANDing查询,mongodb,mongodb-scala,Mongodb,Mongodb Scala,我正在使用mongoDB数据库。其中我有以下格式的收藏 { name : name1 , area: a , country : c} { name : name2 , area: b , country : c} { name : name3 , area: a1 , country : c1} { name : name4 , area: b1 , country : c1} 我想要你喜欢的 select * from coll where (country =c and area =a)

我正在使用mongoDB数据库。其中我有以下格式的收藏

{ name : name1 , area: a , country : c}
{ name : name2 , area: b , country : c}
{ name : name3 , area: a1 , country : c1}
{ name : name4 , area: b1 , country : c1}
我想要你喜欢的

select * from coll where (country =c and area =a) or (country = c1 and area = b1)
在mongodb查询中

我读了很多文件,但没有找到合适的答案

所以如果有人知道,请回复


感谢

默认情况下,mongodb查询中的所有元素都使用
运算符。您可以使用
{“$or”:[…]}
构造指定
运算符,如中所述

您的查询将是:

{ "$or": [ { "country": "c", "area": "a" }, { "country": "c1", "area": "b1" } ] }