当前位置 博文首页 > 你是人间四月天:mongodb查询非空数组的几种方法
本群面相web开发爱好者以及同行,共同探讨研究技术,分享交流经验,帮助新人成长,大牛技术精进,js发展日新月异闭门造车是没有出路的,有问必答,共同进步。求职招聘qq群 626448857
附:web开发资料群 【935069904】
一、elemMatch和ne
db.Collection.find({array:{KaTeX parse error: Expected '}', got 'EOF' at end of input: elemMatch:{ne:null}}})
二、$where
db.Collection.find({$where:“this.array.length>0”})
三、not和size
db.Collection.find({array: {KaTeX parse error: Expected '}', got 'EOF' at end of input: not: {size: 0}}})
四、’.'路径和$exists
db.Collection.find({{‘array.0’: {$exists: 1}}})
五、exists和ne
db.Collection.find({ array: { $exists: true, $ne: [] } })
六、$gt
db.Collection.find({ array: { $gt: [] } })
详情
cs