Database Manual / Reference / mongosh Methods / Databases

db.hello() (mongosh method方法)

db.hello()

New in version 5.0.在版本5.0中新增。

Returns a document that describes the role of the mongod instance.返回一个描述mongod实例角色的文档。

If the mongod is a member of a replica set, then the isWritablePrimary and secondary fields report if the instance is the primary or if it is a secondary member of the replica set.如果mongod副本集的成员,那么isWritablePrimarysecondary字段会报告该实例是副本集中的primary还是secondary成员。

Tip

See: 请参阅:

hello for the complete documentation of the output of db.hello().获取db.hello()输出的完整文档。

Compatibility兼容性

This method is available in deployments hosted in the following environments:此方法在以下环境中托管的部署中可用:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud:云中MongoDB部署的完全托管服务

Note

This command is supported in all MongoDB Atlas clusters. 所有MongoDB Atlas集群都支持此命令。For information on Atlas support for all commands, see Unsupported Commands.有关Atlas支持所有命令的信息,请参阅不支持的命令

  • MongoDB Enterprise: The subscription-based, self-managed version of MongoDB:MongoDB的基于订阅的自我管理版本
  • MongoDB Community: The source-available, free-to-use, and self-managed version of MongoDB:MongoDB的源代码可用、免费使用和自我管理版本