cursor.tailable()
定義
cursor.tailable()
重要
mongosh メソッド
このページでは、
mongosh
メソッドについて記載しています。これは Node.js などの言語固有のドライバーのドキュメントではありません。MongoDB API ドライバーについては、各言語の MongoDB ドライバー ドキュメントを参照してください。
Marks the cursor as tailable keeping it open even when the client exhausts all results.
For use against a 上限付きコレクション only. Using
tailable()
against a non-capped collection returns an error.cursor.tailable()
uses the following syntax:cursor.tailable( { awaitData : <boolean> } ) ~cursor.tailable()
has the following parameter:Parameterタイプ説明awaitData
ブール値
Optional. For use with
DBQuery.Option.tailable
. Sets the cursor to block the query thread when no data is available and await data for a set time instead of immediately returning no data. The cursor returns no data only if the timeout expires.By default, if
maxTimeMS
is set on the command that created the cursor, then the timeout forawaitData
is the remaining time. Otherwise, the default timeout is 1000 milliseconds.You can set a timeout when running
getMore
on a cursor withawaitData
enabled.デフォルトは
false
です。次の値を返します。 The cursor that ~cursor.tailable()
is attached to.
互換性
このメソッドは、次の環境でホストされている配置で使用できます。
MongoDB Atlas はクラウドでの MongoDB 配置のためのフルマネージド サービスです
注意
このコマンドは、すべての MongoDB Atlas クラスターでサポートされています。すべてのコマンドに対する Atlas のサポートについては、「サポートされていないコマンド」を参照してください。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
動作
A tailable cursor performs a collection scan over a 上限付きコレクション. It remains open even after reaching the end of the collection. Applications can continue to iterate the tailable cursor as new data is inserted into the collection.
If awaitData
is true
, when the cursor reaches the end of
the capped collection, mongod
blocks the query thread
for the timeout interval and waits for new data to arrive. When new
data is inserted into the capped collection, mongod
signals the
blocked thread to wake and return the next batch to the client.
See テール可能カーソル.