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

mongodb过滤查询键值

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 14:58:43
Original
1549 people have browsed it

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"键值将不会出现在结果集中。

Related labels:
Statement of this Website
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
Latest Issues
mongodb start
From 1970-01-01 08:00:00
0
0
0
linux - ubuntu14 error installing mongodb
From 1970-01-01 08:00:00
0
0
0
Use of symfony2 mongodb
From 1970-01-01 08:00:00
0
0
0
mongodb _id rename
From 1970-01-01 08:00:00
0
0
0
Parameter understanding of mongodb
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template