码迷,mamicode.com
首页 > 系统相关 > 详细

Find or Query Data with the mongo Shell

时间:2017-03-08 13:56:59      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:util   nec   lte   connected   utils   following   art   ons   数字   

https://docs.mongodb.com/getting-started/shell/query/

Overview

You can use the find() method to issue a query to retrieve data from a collection in MongoDB.

All queries in MongoDB have the scope of a single collection.

 

Queries can return all documents in a collection or only the documents that match a specified filter or criteria.

You can specify the filter or criteria in a document and pass as a parameter to the find() method.

 

The find() method returns query results in a cursor, which is an iterable object that yields documents.

 

Prerequisites

The examples in this section use the restaurants collection in the test database.

For instructions on populating the collection with the sample dataset, see Import Example Dataset.

 

In the mongo shell connected to a running mongod instance, switch to the test database.

use test

 

 

Query for All Documents in a Collection

To return all documents in a collection, call the find() method without a criteria document.

For example, the following operation queries for all documents in the restaurants collection.

db.restaurants.find()

The result set contains all documents in the restaurants collection.

 

如果collection name是数字的,那么

db["713000007000"].find()

 

Find or Query Data with the mongo Shell

标签:util   nec   lte   connected   utils   following   art   ons   数字   

原文地址:http://www.cnblogs.com/chucklu/p/6518787.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!