MongoDB查询空值

栏目: 数据库 · 发布时间: 7年前

内容简介:http://stackoverflow.com/questions/9312067/mongodb-queries-with-null-value本站文章除注明转载外,均为本站原创或编译转载请明显位置注明出处:MongoDB查询空值

我的收藏(MongoDB v 2.0.2)有以下记录:

db.organization.find({})
{ "_id" : 1001, "path" : [ ], "parent" : null }
{ "_id" : 1002, "path" : [ 1001 ], "parent" : NumberLong(1001) }

组织有索引:

db.organization.ensureIndex({"path":1});
db.organization.ensureIndex({"parent":1},{sparse:false});

(注意我放了awarnes sparse:false – 授予null被索引)

但是,执行:

db.organization.find({"parent":null})

返回空集.哪里不对?先谢谢你

我遇到过同样的问题.阅读以下文件后

> querying and nulls

> BSON specification

我尝试查询不同的BSON元素类型,并发现我的null被表示为BSON元素类型6(未定义,不推荐使用),而不是预期的BSON元素类型10(null).

db.collection.find({ field: { "$type" : 6} };

http://stackoverflow.com/questions/9312067/mongodb-queries-with-null-value

本站文章除注明转载外,均为本站原创或编译

转载请明显位置注明出处:MongoDB查询空值


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Algorithm Design Manual

The Algorithm Design Manual

Steve S. Skiena / Springer / 1998-8-1 / GBP 53.91

Contents u Techniques u Introduction to Algorithms u Correctness and Efficiency u Correctness u Efficiency u Expressing Algorithms u Keeping Score u The RAM Model of Computatio......一起来看看 《The Algorithm Design Manual》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具