Database Manual / Reference / mongosh Methods / Connections

Mongo.getReadPrefTagSet() (mongosh method方法)

Mongo.getReadPrefTagSet()
Returns:返回The current read preference tag set for the Mongo() connection object.Mongo()连接对象的当前读取首选项标记集。

See Read Preference for an introduction to read preferences and tag sets in MongoDB. 有关MongoDB中读取首选项和标记集的介绍,请参阅读取首选项。Use getReadPrefTagSet() to return the current read preference tag set, as in the following example:使用getReadPrefTagSet()返回当前读取首选项标记集,如下例所示:

db.getMongo().getReadPrefTagSet()

Use the following operation to return and print the current read preference tag set:使用以下操作返回并打印当前读取的首选项标签集:

printjson(db.getMongo().getReadPrefTagSet());

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的源代码可用、免费使用和自我管理版本