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的更多相关文章

  1. MongoDB - The mongo Shell, Data Types in the mongo Shell

    MongoDB BSON provides support for additional data types than JSON. Drivers provide native support fo ...

  2. MongoDB - MongoDB CRUD Operations, Query Documents, Iterate a Cursor in the mongo Shell

    The db.collection.find() method returns a cursor. To access the documents, you need to iterate the c ...

  3. count failed: not master{ "note" : "from execCommand", "ok" : 0, "errmsg" : "not master" } at src/mongo/shell/query.js:191在SECONDARY节点无法show dbs

    count failed: not master{ "note" : "from execCommand", "ok" : 0, " ...

  4. MongoDB - Introduction of the mongo Shell

    Introduction The mongo shell is an interactive JavaScript interface to MongoDB. You can use the mong ...

  5. MongoDB error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js(转)

    rror: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js 一般这种情况就是:自己指定的数据库,所以不能.自动加 ...

  6. MongoDB - The mongo Shell, mongo Shell Quick Reference

    mongo Shell Command History You can retrieve previous commands issued in the mongo shell with the up ...

  7. MongoDB - The mongo Shell, Write Scripts for the mongo Shell

    You can write scripts for the mongo shell in JavaScript that manipulate data in MongoDB or perform a ...

  8. MongoDB - The mongo Shell, Configure the mongo Shell

    Customize the Prompt You may modify the content of the prompt by setting the variable prompt in the  ...

  9. couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145

    当直接执行./mongo 出现这样的提示:couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145 解决: ...

随机推荐

  1. LaTeX 表格指定宽度并居中

    本系列文章由 @YhL_Leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50532269 在绘制表格的时候,对于特 ...

  2. ArrayList 的实现原理

    ArrayList  是List接口的可变数组的实现.实现了所有可选列表的操作,并包括null值在内的所有元素.此类还提供了一些方法来操作内部用来存储列表的数组大小. ArrayList 的是实现: ...

  3. Nodejs RESTFul架构实践之api篇(转)

    why token based auth? 此段摘自 http://zhuanlan.zhihu.com/FrontendMagazine/19920223 英文原文 http://code.tuts ...

  4. Chrome的JSON View插件

    Chrome的JSON View插件 学习了:http://www.cnplugins.com/zhuanti/five-chrome-json-plugins.html 下载了:http://www ...

  5. hdoj 2222 Keywords Search 【AC自己主动机 入门题】 【求目标串中出现了几个模式串】

    Keywords Search Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others ...

  6. L2CAP数据发送和接收

    ACL 链路在 Bluetooth 中非常重要,一些重要的应用如 A2DP, 基于 RFCOMM 的应用.BNEP等都要建立 ACL 链路,发送/接收ACL 包.跟大家一起来分析 ACL 包发送/接收 ...

  7. 22.boost图模板

    //#pragma warning(disable : 4819) #include <boost/config.hpp> #include <iostream> // for ...

  8. BZOJ 2045 容斥原理

    思路: 同BZOJ 2005 http://blog.csdn.net/qq_31785871/article/details/54314774 //By SiriusRen #include < ...

  9. Django(part2)

    admin site:django自带了admin site,我们需要创建能访问site的用户 #以交互的方式创建超级用户 manage.py createsuperuser 如果要把model加到a ...

  10. 51nod 1307 绳子与重物 (标记父节点更新即可)

    1307 绳子与重物 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 有N条绳子编号 0 至 N - 1,每条绳子后面栓了一个重物重量为Wi,绳子的最大负重为Ci. ...