• 技术文章 >数据库 >MongoDB

    mongodb判断是否为空?

    yangyang2020-05-15 11:38:43原创3768

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

    专题推荐:mongodb
    品易云
    上一篇:mongodb在哪里编辑代码? 下一篇:mongodb能完成哪些功能特性?

    相关文章推荐

    • mongodb怎么删除所有为空的字段• mongodb数据怎么导入新表中?• mongodb为什么数据库?• mongodb怎么存储大文件?

    全部评论我要评论

    © 2021 Python学习网 苏ICP备2021003149号-1

  • 取消发布评论
  • 

    Python学习网