翻译或纠错本页面

cursor.readConcern()

On this page

Definition

cursor.readConcern(level)

3.2 新版功能.

Specify a read concern for the db.collection.find() method.

The readConcern() method has the following form:

db.collection.find().readConcern(<level>)

The readConcern() method has the following parameter:

Parameter Type Description
level string

Read concern level.

Possible read concern values are:

For more formation on the read concern levels, see Read Concern Levels.

Considerations

"majority" Read Concern

To use read concern level of "majority",

Read Your Own Writes

If using "majority" or "linearizable" read concern for read operations, use { w: "majority" } write concern for write operations on the primary to ensure that a single thread can read its own writes.

Linearizable Read Concern Performance

When specifying linearizable read concern, always use maxTimeMS() in case a majority of data bearing members are unavailable.

db.restaurants.find( { _id: 5 } ).readConcern("linearizable").maxTimeMS(10000)

参见

Read Concern