- Reference >
mongoShell Methods >- Cursor Methods >
- cursor.readConcern()
cursor.readConcern()¶
On this page
Definition¶
-
cursor.readConcern(level)¶ New in version 3.2.
Specify a read concern for the
db.collection.find()method.The
readConcern()method has the following form:The
readConcern()method has the following parameter:Parameter Type Description levelstring Read concern level.
Possible read concern values are:
"local". This is the default read concern level."majority". Available for replica sets that use WiredTiger storage engine."linearizable". Available for read operations on theprimaryonly.
For more formation on the read concern levels, see Read Concern Levels.
Considerations¶
"majority" Read Concern¶
To use read concern level of "majority",
- you must start the
mongodinstances with the--enableMajorityReadConcerncommand line option (or thereplication.enableMajorityReadConcernset totrueif using a configuration file). - replica sets must use WiredTiger storage engine and election
protocol version 1.
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.
See also