Para agentes de IA: um índice de documentação está disponível em https://www.mongodb.com/pt-br/docs/llms.txt — as versões de markdown de todas as páginas estão disponíveis anexando .md a qualquer caminho de URL.
Menu Docs

db.logout() (método mongosh)

db.logout()

Obsoleto desde a versão 5.0.

Attempting to use the db.logout() method will write an error message to the log once per logout attempt.

Este método será removido em uma versão futura.

Termina a sessão de autenticação atual. Esta função não terá efeito se a sessão atual não for autenticada.

Observação

If you're not logged in and using authentication, db.logout() has no effect.

Because MongoDB allows users defined in one database to have privileges on another database, you must call db.logout() while using the same database context that you authenticated to.

If you authenticated to a database such as users or $external, you must issue db.logout() against this database in order to successfully log out.

Exemplo

Use the use <database-name> helper in mongosh, or the following db.getSiblingDB() method in an interactive mongosh session or in mongosh shell scripts to change the db object:

db = db.getSiblingDB('<database-name>')

When you have set the database context and db object, you can use the db.logout() to log out of database as in the following operation:

db.logout()

db.logout() function provides a wrapper around the database command logout.

Esse método está disponível em implantações hospedadas nos seguintes ambientes:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

Observação

This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.

  • MongoDB Enterprise: a versão autogerenciada e baseada em assinatura do MongoDB

  • MongoDB Community: uma versão com código disponível, de uso gratuito e autogerenciada do MongoDB

Avalie esta página

Nesta página