定義
cursor.readConcern(level)重要
mongosh メソッド
This page documents a
mongoshmethod. This is not the documentation for a language-specific driver, such as Node.js.MongoDB API ドライバーについては、各言語の「MongoDB ドライバーのドキュメント」を参照してください。
db.collection.find()メソッドの 読み取り保証 を指定します。The
readConcern()method has the following form:db.collection.find().readConcern(<level>) The
readConcern()method has the following parameter:Parameterタイプ説明levelstring
次の読み取り保証レベルが利用できます。
"local"。これは、プライマリとセカンダリに対する読み取り操作での、デフォルトの読み取り保証レベルです。"available"。プライマリおよびセカンダリに対する読み取り操作に使用できます。"available"は、プライマリおよびシャーディングされていないセカンダリに対して"local"と同じように動作します。クエリは、インスタンスの最新データを返します。"majority"。WiredTiger ストレージ エンジンを使用するレプリカセットで使用できます。"linearizable"。primaryの読み取り操作にのみ使用できます。"snapshot"。マルチドキュメントトランザクションおよびマルチドキュメントトランザクション以外の特定の読み取り操作で利用可能です。
読み取り保証 (read concern) のレベルについて詳しくは、「読み取り保証 (read concern) レベル」を参照してください。
互換性
このメソッドは、次の環境でホストされている配置で使用できます。
- MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
注意
This command is supported in all MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
Considerations
自分の書込みを読む
書き込みリクエスト確認をする場合は、非公式のコンシステントセッションを使用して自分の書き込みを読み取ることができます。
線形化可能な読み取り保証によるパフォーマンス
linearizable read concernを指定する場合、データを保持するノードの大部分が利用できない場合に備えて、常にmaxTimeMS()を使用します。
db.restaurants.find( { _id: 5 } ).readConcern("linearizable").maxTimeMS(10000)