On this page本页内容
cursor.
readConcern
(level)¶mongo
Shell Method
This page documents the 本页记录了mongo
shell method, and does not refer to the MongoDB Node.js driver (or any other driver) method. mongo
shell方法,未提及MongoDB Node.js驱动程序(或任何其他驱动程序)方法。For corresponding MongoDB driver API, refer to your specific MongoDB driver documentation instead.有关相应的MongoDB驱动程序API,请参阅特定的MongoDB驱动程序文档。
New in version 3.2.版本3.2中的新功能。
Specify a read concern for the 指定db.collection.find()
method.db.collection.find()
方法的读取关注点。
The readConcern()
method has the following form:readConcern()
方法的形式如下:
The readConcern()
method has the following parameter:readConcern()
方法具有以下参数:
level |
string |
|
"majority"
To use read concern level of 要使用"majority"
, replica sets must use WiredTiger storage engine."majority"
的读关注级别,副本集必须使用WiredTiger存储引擎。
You can disable read concern 对于具有三成员主从仲裁器(PSA)体系结构的部署,可以禁用读关注点"majority"
for a deployment with a three-member primary-secondary-arbiter (PSA) architecture; however, this has implications for change streams (in MongoDB 4.0 and earlier only) and transactions on sharded clusters. "majority"
;然而,这对变更流(仅在MongoDB 4.0及更早版本中)和分片集群上的事务有影响。For more information, see Disable Read Concern Majority.有关更多信息,请参阅禁用读取关注多数。
Starting in MongoDB 3.6, you can use causally consistent sessions to read your own writes, if the writes request acknowledgement.从MongoDB 3.6开始,如果写入请求确认,您可以使用因果一致的会话来读取自己的写入。
Prior to MongoDB 3.6, in order to read your own writes you must issue your write operation with 在MongoDB 3.6之前,为了读取您自己的写入操作,您必须使用{ w: "majority" }
write concern, and then issue your read operation with primary
read preference, and either "majority"
or "linearizable"
read concern.{ w: "majority" }
写入关注点来执行写入操作,然后使用主要读取首选项以及"majority"
或"linearizable"
读取关注点来执行读取操作。
When specifying 指定 可线性化读取关注点时,如果大多数数据承载成员不可用,请始终使用linearizable read concern
, always use maxTimeMS()
in case a majority of data bearing members are unavailable.maxTimeMS()
。
See also参阅