cursor.addOption()

cursor.addOption(<flag>)

Use the cursor.addOption() method on a cursor to add OP_QUERY wire protocol flags, such as the tailable flag.

参数:
  • flag – OP_QUERY wire protocol flag. See MongoDB wire protocol for more information on MongoDB Wire Protocols and the OP_QUERY flags.

For the mongo shell, see the list of cursor flags available in the shell. For the driver-specific list, see your driver documentation.

The following example in the mongo shell adds the DBQuery.Option.tailable flag to ensure the cursor returned from the query is a tailable cursor:

var t = db.myCappedCollection;
var cursor = t.find().addOption(DBQuery.Option.tailable);

警告

Adding incorrect wire protocol flags can cause problems and/or extra server load.

MongoDB Manual (Index)

关于

生态系统

格式

资源