Database Manual / Reference / mongosh Methods / Connections

Mongo.getReadPrefMode() (mongosh method方法)

Mongo.getReadPrefMode()
Returns:返回The current read preference mode for the Mongo() connection object.Mongo()连接对象的当前读取首选项模式。

See Read Preference for an introduction to read preferences in MongoDB. Use getReadPrefMode() to return the current read preference mode, as in the following example:有关MongoDB中读取首选项的介绍,请参阅读取首选项。使用getReadPrefMode()返回当前的读取首选项模式,如下例所示:

db.getMongo().getReadPrefMode()

Use the following operation to return and print the current read preference mode:使用以下操作返回并打印当前读取首选项模式:

print(db.getMongo().getReadPrefMode());

This operation will return one of the following read preference modes:此操作将返回以下读取首选项模式之一:

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部署的完全托管服务
  • 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的源代码可用、免费使用和自我管理版本