mongodb过滤查询键值

WBOY
Release: 2016-06-07 14:58:43
Original
1471 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:
source:php.cn
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 Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!