cursor.addOption()
定義
cursor.addOption(flag)
重要
mongosh メソッド
このページでは、
mongosh
メソッドについて記載しています。これは Node.js などの言語固有のドライバーのドキュメントではありません。MongoDB API ドライバーについては、各言語の MongoDB ドライバー ドキュメントを参照してください。
注意
Deprecated since v3.2
Starting in v3.2, the
cursor.addOption()
operator is deprecated inmongo
. Use available cursor methods instead.Used to change query behavior by setting the flags listed below.
cursor.addOption()
メソッドには次のパラメーターがあります。Parameterタイプ説明flag
flag
For
mongosh
, you can use the cursor flags listed below. For the driver-specific list, see your driver documentation.
互換性
このメソッドは、次の環境でホストされている配置で使用できます。
MongoDB Atlas はクラウドでの MongoDB 配置のためのフルマネージド サービスです
重要
このコマンドは、M0、M2、M5、M10+、および Flex クラスターでサポートが限定されています。詳細については、「 サポートされていないコマンド 」を参照してください。
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
Flags
mongosh
provides several additional cursor flags to
modify the behavior of the cursor.
Flag | 説明 |
---|---|
Sets the cursor not to close once the last data is received, allowing the query to continue returning data added after the initial results were exhausted. | |
Allows querying of a replica secondary. | |
Prevents the server from timing out idle cursors. | |
For use with | |
Sets the cursor to return all data returned by the query at once rather than splitting the results into batches. | |
Sets the cursor to return partial data from a query against a sharded cluster in which some shards do not respond rather than throwing an error. |
例
The following example adds the DBQuery.Option.tailable
flag and the
DBQuery.Option.awaitData
flag to ensure that the query returns a
追尾可能 (tailable) カーソル. The sequence
creates a cursor. After returning the full result set, it waits for the
default interval of 1000 milliseconds so that it can capture
and return additional data added during the query:
var t = db.myCappedCollection; var cursor = t.find().addOption(DBQuery.Option.tailable). addOption(DBQuery.Option.awaitData)
警告
Adding incorrect wire protocol flags can cause problems and/or extra server load.