首页 > 解决方案 > 查找集合中存在且具有非空值或非空值的所有属性

问题描述

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

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

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

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

标签: mongodbrobo3t

解决方案


要不为空也不为空,

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

推荐阅读