Access mongosh
Help
Nesta página
This document provides a brief overview of the help available in mongosh
.
Ajuda da linha de comando
To see the options for running the mongosh
executable and connecting to a deployment, use the --help
option from the command line:
mongosh --help
mongosh
Ajuda da Shell
To see the help available in the mongosh
console, type help
inside a running mongosh
console:
help
Ajuda do Banco de Dados
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 thedb
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 parashow dbs
.DicaThe 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, rundb.help()
:db.help()
Ajuda de coleção
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 theshow 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()
Ajuda do cursor
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.
mongosh
Usage provides guidance on how to usemongosh
.mongosh
Methods lists available methods.