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 解决: ...
随机推荐
- 重启rsyslog服务时出现问题(误删/var/log/messages解决方案)
今天修改了/etc/rsyslog.conf中的内容后,想着要通过systemctl restart rsyslog重启服务,但是执行完命令后,总感觉/etc/rsyslog.conf中修改的内容没有 ...
- WinServer-IIS-请求筛选
这个实在太多了,可以比较好的控制网站的访问 来自为知笔记(Wiz)
- maven小知识点
Maven 使用惯例优于配置的原则 .它要求在没有定制之前,所有的项目都有如下的结构: 一个 maven 项目在默认情况下会产生 JAR 文件,另外 ,编译后 的 classes 会放在 basedi ...
- POJ2449题解
先讲一个为了少打一些代码而滥用继承终于接受慘痛教训的故事. #include <cstdio> #include <algorithm> #include <queue& ...
- 文档相关命令-cat命令查看一个文件
用于查看一个文件的内容并将其显示在屏幕上 cat 后直接加上文件名 -n 表示显示行号 cat -n dirb/filee -A 显示所有内容包括特殊字符 cat -A dirb/filee
- HTML5与CSS3权威指南之CSS3学习记录
title: HTML5与CSS3权威指南之CSS3学习记录 toc: true date: 2018-10-14 00:06:09 学习资料--<HTML5与CSS3权威指南>(第3版) ...
- sicily 1342 开心的金明 (动规)
刷一下简单的背包问题 以下为代码: //1342. 开心的金明 #include <iostream> using namespace std; #define MAX(a,b) a> ...
- Android 数据存取
Android提供了Preference(配置),File(文件),SQLite数据和网络几种数据存取方式 SharedPreference提供了一种轻量级的数据存取方法,应用场合主要是比较少的配置信 ...
- Glide中的回调:targets
Glide隐藏了一大推复杂的在后台的场景,Glide做了所有的网络请求和处理在后台线程中,准备好了切回到ui线程后更新ImageView. 假设ImageView不再是图像的最后一步.我们只要Bitm ...
- Servlet学习(四)——response
1.概述 在创建Servlet时会覆盖service()方法,或doGet()或doPost(),这些方法都有两个参数,一个是代表请求的request和代表响应response. service方法中 ...