我正在使用與$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}}])。漂亮()我必須把$或 –