mongodb判断是否为空?

473次阅读
没有评论

mongodb判断是否为空?

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自学网。

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:MongoDB2022-12-06发表,共计368字。
新手QQ群:570568346,欢迎进群讨论 Python51学习