品易云推流 关闭
文章详情页
文章 > MongoDB > mongodb判断是否为空?

mongodb判断是否为空?

头像

yang

2020-05-15 11:38:433917浏览 · 0收藏 · 0评论

mongodb判断是否为空的方法:

方法一:{"field1.0":{$exists: true}} (推荐)

db.testcollection.find({"field1.0":{$exists: true}})

方法二:$elemMatch:{$ne:null}

db.testcollection.find({"field1":{$elemMatch:{$ne:null}}})

方法三:$where:"this.field1.length>0"

db.testcollection.find({$where:"this.field1.length>0"})

方法四:{"field1":{$gt: []}}

db.testcollection.find({"field1":{$gt: []}})

更多mongodb相关文章请关注python自学网

关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

底部广告图