【问题标题】:Find all properties which exists in collection and has not-null or not empty value查找集合中存在且具有非空值或非空值的所有属性
【发布时间】:2020-07-30 20:34:46
【问题描述】:

我正在尝试使用 Robo3T 在我的集合中查找所有属性 InternalCode 不为空且不为空的属性

db.getCollection('db1.customer').find({ InternalCode : { $exists: true, $ne: null } })

这将返回所有具有该属性且设置为非空的文档。

如何处理我想要非空而不是空值的场景?

【问题讨论】:

  • 你试过$nin:[null,""]
  • 是的,刚刚尝试过,它正在工作。
  • 我会把这个作为答案来帮助那些寻求这类问题的人

标签: mongodb robo3t


【解决方案1】:

不为空不为空,

db.getCollection('db1.customer').find({ InternalCode : { $exists: true, $nin:[null,""] } })

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-25
    • 1970-01-01
    • 2018-07-04
    • 2020-10-13
    • 1970-01-01
    相关资源
    最近更新 更多