当前位置:首页 > 云计算 > 正文内容

mongodb判断是否为空?

2022-05-04 03:25:36云计算1

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

本网站文章仅供交流学习 ,不作为商用, 版权归属原作者,部分文章推送时未能及时与原作者取得联系,若来源标注错误或侵犯到您的权益烦请告知,我们将立即删除.

本文链接:https://www.xibujisuan.cn/15756.html

标签: Python