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的更多相关文章
- 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 ...
- 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 ...
- 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, " ...
- MongoDB - Introduction of the mongo Shell
Introduction The mongo shell is an interactive JavaScript interface to MongoDB. You can use the mong ...
- 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 一般这种情况就是:自己指定的数据库,所以不能.自动加 ...
- 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 ...
- 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 ...
- 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 ...
- 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 解决: ...
随机推荐
- ubuntu设置PATH
试了好多遍,多无效.. 最后在/etc/enviroment下设置才有效. 不过让有一些未解问题 我使用sudo su 进入到root用户权限,设置完成的. 重新使用sudo -s进入root用户权限 ...
- java properties类读取配置文件
1.JAVA Properties类,在java.util包里,具体类是java.util.properties.Properties类继承自Hashtable类并且实现了Map接口,也是使用一种键值 ...
- sigprocmask和信号阻塞
注意阻塞和忽略,是有区别的. 阻塞只是暂时的,忽略是就没了. 参数:how:用于指定信号修改的方式,可能选择有三种:SIG_BLOCK //加入信号到进程屏蔽.SIG_UNBLOCK //从进程屏蔽里 ...
- 各种List、Map、Set的比較
前言:Java中用不同的数据结构(哈希表/动态数组/平衡树/链表)实现了不同的集合接口(List/Map/Set).大多数情况下,集合类被用于不须要线程安全地环境,所以后来的集合实现都没有再採用同步以 ...
- Codeforces 10A-Power Consumption Calculation(模拟)
A. Power Consumption Calculation time limit per test 1 second memory limit per test 256 megabytes in ...
- 好莱坞原则—Spring的IOC容器
IOC容器的概念,之前在学习SSH的时候,就有接触过.但那时候也仅仅是知道这么个概念,认为它非常难理解.事实上并非它难理解,而是我并没有停下来好好对它总结梳理过. IOC(Inversion of C ...
- chrome控制台常用技巧有哪些
chrome控制台常用技巧有哪些 一.总结 一句话总结:别的里面支持的快捷键,chrome里面几乎都支持,比如sublime中的ctrl+d,其实真是一通百通,都差不多的 1.chrome如何快速切换 ...
- hdoj--1016--Prime Ring Problem(递归回溯)
Prime Ring Problem Time ...
- 新型查询系统impala
这羊头很酷... Apache Impala是Apache Hadoop的开源本地分析数据库.Impala由Cloudera,MapR,Oracle和Amazon提供. 在Hadoop上进行BI风格的 ...
- jqGrid收藏的链接
http://zld406504302.iteye.com/blog/1694017 http://blog.csdn.net/jiudihanbing/article/details/2455902 ...