關於mongodb or和and的坑

我想寫一個select * from job where updateTime<>0 and updateTime is not null

正常情況下mongodbl的find()中所有的條件是and,但是以下寫法查詢出來的結果卻是or

db.Job.find({ 'updateTime': {$exists: true},'updateTime': {$ne:0} })

改寫後:

db.Job.find({
$and:[{updateTime: {$exists: true}},{updateTime: { $ne : 0 }}]
})
才實現and

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章