Find or Query Data with the mongo Shell

Posted Chuck Lu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Find or Query Data with the mongo Shell相关的知识,希望对你有一定的参考价值。

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的主要内容,如果未能解决你的问题,请参考以下文章

Couldn‘t find meta-data for provider with authority com.wust.camerademo

SQLAlchemy query with OR/AND/like common filters

运行爬虫遇到奇葩的问题 bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requested: lxml.

[!] Unable to find a pod with name, author, summary, or description matching ‘ ‘

[!] Unable to find a pod with name, author, summary, or description matching ‘ ‘

20161209pod search 'fmdb'提示[!] Unable to find a pod with name, author, summary, or descripti