本文介绍了具有空值的 MongoDB 查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的收藏(MongoDB v 2.0.2)有以下记录:
My collection (MongoDB v 2.0.2) has following records:
dbanization.find({}) { "_id" : 1001, "path" : [ ], "parent" : null } { "_id" : 1002, "path" : [ 1001 ], "parent" : NumberLong(1001) }organization 有索引:
dbanization.ensureIndex({"path":1}); dbanization.ensureIndex({"parent":1},{sparse:false});(注意我把 awarnes sparse : false - 授予 null 被索引)但是,执行:
(note I put awarnes sparse : false - to grant that null is indexed) But, executing:
dbanization.find({"parent":null})返回空集.怎么了?提前谢谢您
Returns empty set. What is wrong? Thank you in advance
推荐答案我遇到了同样的问题.阅读以下文档后
I had the same issue. After reading the following documents
- 查询和空值
- BSON 规范
我尝试查询不同的 BSON 元素类型,发现我的 null 表示为 BSON 元素类型 6(未定义,已弃用),而不是预期的 BSON 元素类型 10(空值).
I tried to query for the different BSON element types and found that my null was represented as a BSON element type 6 (undefined, deprecated) instead of the expected BSON element type 10 (null).
db.collection.find({ field: { "$type" : 6} };更多推荐
具有空值的 MongoDB 查询
发布评论