MongoDB Documentation — MongoDB Shell
Menu Docs

Access mongosh Help

This document provides a brief overview of the help available in mongosh.

To see the options for running the mongosh executable and connecting to a deployment, use the --help option from the command line:

mongosh --help

To see the help available in the mongosh console, type help inside a running mongosh console:

help

You can view database level information from inside the mongosh console:

  • By default mongosh shows the current database in the prompt. You can also see the current database by running the db command:

    db
  • Para visualizar a lista de bancos de dados disponíveis para você no servidor, utilize o comando show dbs:

    show dbs

    show databases é um alias para show dbs.

    Dica

    The list of databases will change depending on your access authorizations. For more information on access restrictions for viewing databases, see listDatabases.

  • To see help for the available database methods you can use with the db object, run db.help():

    db.help()

You can view collection level information from inside the mongosh console.

Esses métodos de ajuda aceitam um nome de coleção, <collection>, mas você também pode usar o termo genérico, "coleção" ou até mesmo uma coleção que não existe.

  • By default mongosh shows the current database in the prompt. 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 collection objects use db.<collection>.help() method:

    db.collection.help()
  • To see the help for a particular method, use db.<collection>.<method>.help():

    db.collection.getIndexes.help()

Use cursor methods to modify read operations that use find().

  • Para listar os métodos de manuseio do modificador e cursor disponíveis, utilize o comando db.collection.find().help():

    db.collection.find().help()

Esta chamada de ajuda aceita um nome de coleção, <collection>, mas você também pode usar o termo genérico, "coleção", ou até mesmo uma coleção que não existe.

Alguns métodos úteis para lidar com cursores são:

  • hasNext() verificar se o cursor tem mais documentos.
  • next() retornar o próximo documento e move a posição do cursor para frente por um.
  • forEach(<function>) applies the <function> to each document returned by the cursor.

For a list of available cursor methods, see Cursor.

Dica
Veja também:
Dê Feedback