MongoDB 空值數組查詢


mongdb非空數組查詢

db.idap_zl.insert({array:[]})

db.idap_zl.insert({array:[1,2,3,4,5]})

db.idap_zl.find({array:{$elemMatch:{$ne:null}}})

 

一、elemMatchelemMatch和ne

db.Collection.find({array:{$elemMatch:{$ne:null}}})

二、$where

db.Collection.find({$where:"this.array.length>0"})

三、notnot和size

db.Collection.find({array: {$not: {$size: 0}}})

四、'.'路徑和$exists

db.Collection.find({{'array.0': {$exists: 1}}})

五、existsexists和ne

db.Collection.find({ array: { $exists: true, $ne: [] } })

六、$gt

db.Collection.find({ array: { $gt: [] } })


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM