Mongodb-the MONGO Shell, Access the MONGO shell help

Source: Internet
Author: User
Tags wrapper mongo shell

In addition to the documentation in the MongoDB Manual, the MONGO Shell provides some additional information in I TS "Online" Help system. This document provides a overview of accessing this Help information.

Command line Help

The list of options and help for starting the MONGO shell with 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 the list of databases in the server, use the show dbs command:
    Show DBS

    New in version 2.4: Show Databases is now a 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 would return the implementation of the method Db.updateuser ():
    Db.updateuser

Collection Help

In the MONGO Shell:

  • The list of collections in the current database, use the show Collections command:
    Show collections
  • To see the methods available on the collection objects (e.g. db.<collection>) , use the db.< Collection>.help () method:
    Db.collection.help ()

    <collection> Can is the name of a collection that exists, although specify a collection that doesn ' T exist.

  • To see the collection method implementation, type the db.<collection>.<method> name without the Paren Thesis (()), as in the following example which would return the implementation of the Save ()method:
    Db.collection.save

Cursor Help

When you perform read Operations with the  find ()  method in the &NBSP;mongo  shell , you can use various cursor methods to modify THE&NBSP;find ()  behavior and various JavaScript methods to handle the cursor returned from the < TT class= "XRef mongodb mongodb-method docutils literal" >find ()  method.

    • To list the available modifier and cursor handling methods with the Db.collection.find (). Help () command:
      Db.collection.find (). Help ()

      <collection> Can is the name of a collection that exists, although 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 would return the implementation of the ToArray () Method
      Db.collection.find (). ToArray

Some useful methods for handling cursors is:

    • Hasnext () which checks whether the cursor has a 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 docum ENT 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.