mongdb非空数组查询

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

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

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

 

一、elemMatch和ne

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

二、$where

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

三、not和size

db.Collection.find({array: {$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: [] } })

相关文章:

  • 2021-12-23
  • 2021-11-30
  • 2022-01-25
  • 2021-12-29
  • 2022-12-23
  • 2022-01-14
  • 2021-05-27
猜你喜欢
  • 2022-12-23
  • 2021-12-06
  • 2022-01-17
  • 2022-02-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案