我正在使用与$match
,$project
和$geonear
流水线运算符的汇总流水线。
在每个收集的我场为工作日,如:
repeat_every_monday =true
,repeat_every_tuesday=true
,
所有工作日相同的序列。
现在,如果今天是星期二,然后我不得不把$or
条件在我的管道运营商也获取所有的纪录,之前的数据,其中被标记为repeat_every_tuesday=true
,
我想表达的类似条件操作
if (name=="pankaj" and "test"=="false" || "test"==true)
这是我迄今所做的:
db.test.aggregate([
{'$match':{"name":"pankaj","test":false,}},
{'$project':{_id:1,name:1,test:1,sir:1}}
]).pretty()
在这里我必须把$or
?
I have test collection and data is as below:
db.test.find().pretty()
{
"_id" : ObjectId("56e79492f286d94702cf4e31"),
"name" : "pankaj",
"test" : true,
"sir" : "cheema"
}
{
"_id" : ObjectId("56e7abb3f286d94702cf4e32"),
"name" : "pankaj",
"test" : false,
"sir" : "cheema"
}
I want a aggregate query with $match which should give me result where name is =pankaj and test is either true or false .
For example in sql :
Select * from test where name=pankaj or test=false or test =true.
好了,究竟是你的问题? – Philipp
我想用$或我的聚合。 –
db.test.aggregate([{'$ match':{“name”:“pankaj”,“test”:false,}},{'$ project':{_ id:1,name:1,test:1 ,先生:1}}])。漂亮()我必须把$或 –