定義
cursor.maxAwaitTimeMS(<time limit>)重要
mongosh メソッド
This page documents a
mongoshmethod. This is not the documentation for a language-specific driver, such as Node.js.MongoDB API ドライバーについては、各言語の「MongoDB ドライバーのドキュメント」を参照してください。
Capped コレクション の 追尾可能 (tailable) カーソル クエリに一致する新しいドキュメントをサーバーが待機する最大時間を指定します。クエリによって返されたカーソルを反復処理する方法の詳細については、「
mongoshでのカーソルの反復処理 」を参照してください。The
maxAwaitTimeMS()method has the following prototype form:db.collection.find( { <query> }, { <projection> } ).tailable( { awaitData: true } ).maxAwaitTimeMS( <milliseconds> ) The
maxAwaitTimeMS()method has the following parameter:Parameterタイプ説明millisecondsinteger
新しいドキュメントの最大待機時間を指定します。
重要
This method, maxAwaitTimeMS(), sets a limit on how long a tailable cursor waits for the next response. maxTimeMS() sets a limit on total processing time.
互換性
このメソッドは、次の環境でホストされている配置で使用できます。
- 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 のバージョン
例
Capped salesコレクションをクエリして、エージェント メトリクスの月間売上合計を見つけます。
db.sales.find( { agent: "Mary Kay" }, { _id: 0, agent: 1, weeklyTotal: 1 } ).tailable( { awaitData: true } ).maxAwaitTimeMS( 1000 )
The highlighted line creates a tailable cursor on the sales collection. The maxAwaitTimeMS() sets a one second maximum wait time for the next cursor update.