MongoDB - The mongo Shell, Access the mongo Shell Help
In addition to the documentation in the MongoDB Manual, the mongo shell provides some additional information in its “online” help system. This document provides an overview of accessing this help information.
Command Line Help
To see the list of options and help for starting the mongo shell, use the --help option from the command line:
mongo --help
Shell Help
To see the list of help, in the mongo shell, type help:
help
Database Help
In the mongo shell:
- To see the list of databases on the server, use the show dbs command:
show dbs
New in version 2.4: show databases is now an alias for show dbs
- To see the list of help for methods you can use on the db object, call the db.help() method:
db.help()
- To see the implementation of a method in the shell, type the db.<method name> without the parenthesis (()), as in the following example which will return the implementation of the method db.updateUser():
db.updateUser
Collection Help
In the mongo shell:
- To see the list of collections in the current database, use the show collections command:
show collections
- To see the help for methods available on the collection objects (e.g. db.<collection>), use the db.<collection>.help() method:
db.collection.help()
<collection> can be the name of a collection that exists, although you may specify a collection that doesn’t exist.
- To see the collection method implementation, type the db.<collection>.<method> name without the parenthesis (()), as in the following example which will return the implementation of the save()method:
db.collection.save
Cursor Help
When you perform read operations with the find() method in the mongo shell, you can use various cursor methods to modify the find() behavior and various JavaScript methods to handle the cursor returned from the find() method.
- To list the available modifier and cursor handling methods, use the db.collection.find().help() command:
db.collection.find().help()
<collection> can be the name of a collection that exists, although you may specify a collection that doesn’t exist.
- To see the implementation of the cursor method, type the db.<collection>.find().<method> name without the parenthesis (()), as in the following example which will return the implementation of the toArray() method:
db.collection.find().toArray
Some useful methods for handling cursors are:
- hasNext() which checks whether the cursor has more documents to return.
- next() which returns the next document and advances the cursor position forward by one.
- forEach(<function>) which iterates the whole cursor and applies the <function> to each document returned by the cursor. The <function> expects a single argument which corresponds to the document from each iteration.
For examples on iterating a cursor and retrieving the documents from the cursor, see cursor handling. See also Cursor for all available cursor methods.
Wrapper Object Help
To get a list of the wrapper classes available in the mongo shell, such as BinData(), type help misc in the mongo shell:
help misc
MongoDB - The mongo Shell, Access the mongo Shell Help的更多相关文章
- 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 ...
- MongoDB的安装,mongod和mongo的区别
一. mongoDB安装路径 安装路径(最新4.0.11):https://www.mongodb.com/download-center/community?jmp=nav 建议另外找路径下载,外网 ...
- MongoDB学习笔记:文档Crud Shell
MongoDB学习笔记:文档Crud Shell 文档插入 一.插入语法 db.collection.insertOne() 将单个文档插入到集合中.db.collection.insertMan ...
- MONGODB(三)——Java操作Mongo
相比于java调用MySqlApI来操作数据库,调用Mongo要简洁容易的多.通过一个简单的样例,很容易地就可以上手 一.导入Jar包 添加Monog支持Java的jar包,这里使用的是2.9.3 & ...
- 交互式shell和非交互式shell、登录shell和非登录shell的区别
交互式shell和非交互式shell.登录shell和非登录shell的区别.首先,这是两个不同的维度来划分的,一个是是否交互式,另一个是是否登录. 交互式shell和非交互式shell(intera ...
- linux中的shell脚本编程---初识shell
Shell是用户与Linux或Unix内核通信的工具,shell编程指的并不是编写这个工具,而是指利用现有的shell工具进行编程,写出来的程序是轻量级的脚本,我们叫做shell脚本. Shell的语 ...
- Ubuntu下把缺省的dash shell修改为bash shell
Ubuntu下缺省使用的是shell是dash,而不是bash.从/bin/sh软连接的指向可以看出这点. dash shell 虽然比bash shell更轻便,但是它并不支持所有的语法,运行she ...
- Shell编程-11-子Shell和Shell嵌套
目录 什么是子Shell 子Shell产生的途径 Shell脚本调用模式 什么是子Shell 子Shell的概念其实是贯穿整个Shell的,如果想要更好的理解和写Shell脚本则必须要了解子S ...
- [shell]shell 中| && || () {} 用法以及shell的逻辑与或非
转自:https://www.jianshu.com/p/617c1ee1e46e | 运算符 管道符号,是unix一个很强大的功能,符号为一条竖线:"|".用法: command ...
随机推荐
- wikioi 3038 3n+1问题
题目描述 Description 3n+1问题是一个简单有趣而又没有解决的数学问题.这个问题是由L. Collatz在1937年提出的.克拉兹问题(Collatz problem)也被叫做hailst ...
- DISCUZ X2更换域名注意事项
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- Chrysler -- CCD (Chrysler Collision Detection) Data Bus
http://articles.mopar1973man.com/general-cummins/34-engine-system/81-ccd-data-bus CCD (Chrysler Coll ...
- SQL with(unlock)与with(readpast) (转)
所有Select加 With (NoLock)解决阻塞死锁,在查询语句中使用 NOLOCK 和 READPAST 处理一个数据库死锁的异常时候,其中一个建议就是使用 NOLOCK 或者 READPAS ...
- jQuery 动态加载树
本案例中用到了jquery的 tree插件,在本文的附件中可以下载 jsp代码: <%@ page language="java" import="java.uti ...
- Codeforces Round #181 (Div. 2) C. Beautiful Numbers 排列组合 暴力
C. Beautiful Numbers 题目连接: http://www.codeforces.com/contest/300/problem/C Description Vitaly is a v ...
- 如何在XAF中显示自定义窗体和控件
https://www.devexpress.com/Support/Center/Example/Details/E911
- iOS开发——路径篇&混编路径与全局宏路径
混编路径与全局宏路径 最近在做东西的时候有一个地方要用到一个第三方库的,但是目前swift版的还没有找到,自己又不想写(其实是不会写),所以就想到了混编,但是中间出现了好多问题,其中印象最深的就是桥接 ...
- andorid
js内存泄露 三分面加七分水 —— 十分糊涂 膝盖上打瞌睡 —— 自己靠自己 不当家,不知柴米贵:不生子,不知父母恩. 水落现石头,日久见人心. sqllite http://wenku.baidu. ...
- 关于JS加载的问题
一些绑定事件之类的行为,如果让他放于外部文件中,或者头部,则会引起所需的内容没有加载出来,找不到Element,导致实现失败.解决这一问题的办法主要采用window.onload事件进行处理,因为在w ...