Home >Database >Mysql Tutorial >mongodb过滤查询键值

mongodb过滤查询键值

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 14:58:431578browse

mongodb过滤查询键值 find的第二个参数,过滤键值。 例如:我们想查询name键值,不想显示其他的: [javascript] db.XXX.find({}, {name:1}); 这样,显示的键值是_id和name。 想过滤掉某个键值,例如gender键值,那么可以这样做: [javascript] db.XXX.find({

mongodb过滤查询键值

 

find的第二个参数,过滤键值。

 

例如:我们想查询"name"键值,不想显示其他的:

 

[javascript] 

db.XXX.find({}, {"name":1});  

 

这样,显示的键值是_id和name。

想过滤掉某个键值,例如gender键值,那么可以这样做:

 

[javascript] 

db.XXX.find({}, {"gender":0});  

 

这样"gender"键值将不会出现在结果集中。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn