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 ...
随机推荐
- Thread Pool Engine, and Work-Stealing scheduling algorithm
http://pages.videotron.com/aminer/threadpool.htm http://pages.videotron.com/aminer/zip/threadpool.zi ...
- C# WinForm使用Aspose.Cells.dll 导出导入Excel/Doc 完整实例教程
1.添加引用: Aspose.Cells.dll(我们就叫工具包吧,可以从网上下载.关于它的操作我在“Aspose.Cells操作说明 中文版 下载 Aspose C# 导出Excel 实例”一文中的 ...
- Eclipse配置PyDev插件
安装python解释器 安装PyDev: 首先需要去Eclipse官网下载:http://www.eclipse.org/,Eclipse需要JDK支持,如果Eclipse无法正常运行,请到Java官 ...
- Codeforces Round #308 (Div. 2) C. Vanya and Scales dfs
C. Vanya and Scales Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/552/p ...
- Android定时器,推荐ScheduledThreadPoolExecutor
Android定时器,推荐ScheduledThreadPoolExecutor 官方网址:http://developer.android.com/reference/java/util/Timer ...
- 如何快速检查js语法学习Javascript
这里给大家推荐一个快速进行语法检查的方法,可以发现绝大多数语法错误,也可以作为在线编辑器,提高编程效率. 地址:http://www.jslint.com/ 同时推荐一个在线学习Javascript的 ...
- python代码查询港澳通行证办理进度
查询港澳通行证办理进度查询的python 3.3代码.利用socket请求相关网站,获得结果后利用正则找出办理进度.其实用urllib代码会更简洁,不过当时在下还不熟悉urllib~ 直接上代码: i ...
- discuz(dz) SSO(单点,同歩,异步)登录 --转
原文地址:http://fc-lamp.blog.163.com/blog/static/1745666872012762520123/ discuz(dz) SSO(单点,同歩,异步)登录 一般流 ...
- LeetCode10 Regular Expression Matching
题意: Implement regular expression matching with support for '.' and '*'. '.' Matches any single chara ...
- 用HashSet的add方法谈hashcode和equals方法重写
本文主要通过用HashSet的add方法讲一下hashCode和equals方法重写.错误的地方望指正. 1.了解HashSet的add方法 了解一个方法的好办法是看源码,所以先看源码 private ...