On this page本页内容
cursor.
addOption
(flag)¶mongo
Shell Method
This page documents the 本页记录了mongo
shell method, and does not refer to the MongoDB Node.js driver (or any other driver) method. mongo
shell方法,未提及MongoDB Node.js驱动程序(或任何其他驱动程序)方法。For corresponding MongoDB driver API, refer to your specific MongoDB driver documentation instead.有关相应的MongoDB驱动程序API,请参阅特定的MongoDB驱动程序文档。
Deprecated since v3.2
Starting in v3.2, the 从v3.2开始,cursor.addOption()
operator is deprecated in the mongo
shell. mongo
shell中不推荐使用cursor.addOption()
运算符。In the 在mongo
shell, use available cursor methods instead.mongo
shell中,使用可用的游标方法。
Adds 添加OP_QUERY
wire protocol flags, such as the tailable
flag, to change the behavior of queries.OP_QUERY
wire协议标志,例如tailable
标志,以更改查询的行为。
The cursor.addOption()
method has the following parameter:cursor.addOption()
方法具有以下参数:
flag |
flag | OP_QUERY mongo shell, you can use the cursor flags listed below. mongo shell,可以使用下面列出的游标标志。 |
The mongo
shell provides several additional cursor flags to modify the behavior of the cursor.mongo
shell提供了几个额外的游标标志来修改游标的行为。
|
|
|
|
|
|
|
.. data:: DBQuery.Option.tailable 配合使用;将游标设置为阻塞并等待数据一段时间,而不是不返回任何数据。 |
|
|
|
The following example adds the 下面的示例添加了DBQuery.Option.tailable
flag and the DBQuery.Option.awaitData
flag to ensure that the query returns a tailable cursor. DBQuery.Option.tailable
标志和DBQuery.Option.awaitData
标志,以确保查询返回可裁剪的游标。The sequence creates a cursor that will wait for few seconds after returning the full result set so that it can capture and return additional data added during the query:序列会创建一个游标,返回完整结果集后会等待几秒钟,以便捕获并返回查询过程中添加的其他数据:
Warning
Adding incorrect wire protocol flags can cause problems and/or extra server load.添加不正确的有线协议标志可能会导致问题和/或额外的服务器负载。