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

  1. 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  ...

  2. MongoDB的安装,mongod和mongo的区别

    一. mongoDB安装路径 安装路径(最新4.0.11):https://www.mongodb.com/download-center/community?jmp=nav 建议另外找路径下载,外网 ...

  3. MongoDB学习笔记:文档Crud Shell

    MongoDB学习笔记:文档Crud Shell   文档插入 一.插入语法 db.collection.insertOne() 将单个文档插入到集合中.db.collection.insertMan ...

  4. MONGODB(三)——Java操作Mongo

    相比于java调用MySqlApI来操作数据库,调用Mongo要简洁容易的多.通过一个简单的样例,很容易地就可以上手 一.导入Jar包 添加Monog支持Java的jar包,这里使用的是2.9.3 & ...

  5. 交互式shell和非交互式shell、登录shell和非登录shell的区别

    交互式shell和非交互式shell.登录shell和非登录shell的区别.首先,这是两个不同的维度来划分的,一个是是否交互式,另一个是是否登录. 交互式shell和非交互式shell(intera ...

  6. linux中的shell脚本编程---初识shell

    Shell是用户与Linux或Unix内核通信的工具,shell编程指的并不是编写这个工具,而是指利用现有的shell工具进行编程,写出来的程序是轻量级的脚本,我们叫做shell脚本. Shell的语 ...

  7. Ubuntu下把缺省的dash shell修改为bash shell

    Ubuntu下缺省使用的是shell是dash,而不是bash.从/bin/sh软连接的指向可以看出这点. dash shell 虽然比bash shell更轻便,但是它并不支持所有的语法,运行she ...

  8. Shell编程-11-子Shell和Shell嵌套

    目录 什么是子Shell 子Shell产生的途径 Shell脚本调用模式 什么是子Shell     子Shell的概念其实是贯穿整个Shell的,如果想要更好的理解和写Shell脚本则必须要了解子S ...

  9. [shell]shell 中| && || () {} 用法以及shell的逻辑与或非

    转自:https://www.jianshu.com/p/617c1ee1e46e | 运算符 管道符号,是unix一个很强大的功能,符号为一条竖线:"|".用法: command ...

随机推荐

  1. OpenCV 图像处理学习笔记(一)

    解读IplImage结构 typedef struct _IplImage { int nSize;                    /* IplImage大小 */ int ID;       ...

  2. 推荐系统之基于二部图的个性化推荐系统原理及C++实现

    1.引言 许多网站都喜欢让用户点击“喜欢/不喜欢”,“顶/反对”,也正是这种很简单的信息也可以利用起来对用户进行推荐!这里介绍一种基于网络结构的推荐系统! 由于推荐系统深深植根于互联网,用户与用户之间 ...

  3. CodeForces 173B Chamber of Secrets spfa

    Chamber of Secrets 题目连接: http://codeforces.com/problemset/problem/173/B Description "The Chambe ...

  4. SGU 532. Building Foundation 暴力

    532. Building Foundation 题目连接: http://acm.sgu.ru/problem.php?contest=0&problem=532 Description A ...

  5. 网易新闻优化APK下载链接

    你好,欢迎你的访问! 本次是APK包的下载链接: 点我下载 这是我目前实现的效果,正在完善中...

  6. TypeHandler的简单实例

    转自:http://ccchhhlll1988-163-com.iteye.com/blog/1420149 TypeHandler是MyBatis config文件中可选的配置选项,其可以对实体属性 ...

  7. c++笔试题两道,求解当中一道

    1.Implement a functionthat prints the numbers from 1 to 100.But for multiples of three(3) print &quo ...

  8. Qt多线程学习:创建多线程

    [为什么要用多线程?] 传统的图形用户界面应用程序都仅仅有一个运行线程,而且一次仅仅运行一个操作.假设用户从用户界面中调用一个比較耗时的操作,当该操作正在运行时,用户界面一般会冻结而不再响应.这个问题 ...

  9. 云服务器 ECS Linux 误删除文件恢复方法介绍

    云服务器 ECS Linux 下,rm -rf  意味着一旦删除的文件是无法挽回的.但如果在没有文件覆盖操作的前提下,可以先尝试相关方式进行文件恢复. 本文对此进行简要说明. https://help ...

  10. PS拾色器(前景色背景色)快捷键

    快捷键 I 是拾色器 X 是前后色切换