On this page本页内容
cursor.readConcern(level)
This is a mongosh
method. This is not the documentation for Node.js
or other programming language specific driver methods.
In most cases, mongosh
methods work the same way as the legacy mongo
shell methods. However, some legacy methods are unavailable in mongosh
.
For the legacy mongo
shell documentation, refer to the documentation for the corresponding MongoDB Server release:
For MongoDB API drivers, refer to the language specific MongoDB driver documentation.有关MongoDB API驱动程序,请参阅特定语言的MongoDB驱动程序文档。
Specify a read concern for the 指定db.collection.find()
method.db.collection.find()
方法的读取关注点。
The readConcern()
method has the following form:readConcern()
方法具有以下形式:
db.collection.find().readConcern(<level>)
The readConcern()
method has the following parameter:readConcern()
方法具有以下参数:
level | string |
|
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" }
写关注点发出写操作,然后使用primary
读首选项发出读操作,或者使用"majority"
或"linearizable"
读关注点。
When specifying 指定线性化读取关注点时,如果大多数数据承载成员不可用,请始终使用linearizable read concern
, always use maxTimeMS()
in case a majority of data bearing members are unavailable.maxTimeMS()
。
db.restaurants.find( { _id: 5 } ).readConcern("linearizable").maxTimeMS(10000)