创新互联www.cdcxhl.cn八线动态BGP香港云服务器提供商,新人活动买多久送多久,划算不套路!
这篇文章主要介绍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判断是不是为空的方法的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联-成都网站建设公司行业资讯频道!