On this page本页内容
New in version 3.2.版本3.2中的新功能。
killCursors
¶Kills the specified cursor or cursors for a collection. MongoDB drivers use the killCursors
command as part of the client-side cursor implementation.
Note
In general, applications should not use the killCursors
command directly.
The killCursors
command must be run against the database of the collection whose cursors you wish to kill.
To run killCursors, use the db.runCommand( { <command> } )
method.
The command has the following form:
killCursors |
string | The name of the collection. |
cursors |
array | The ids of the cursors to kill. |
comment |
any |
A comment can be any valid BSON type (string, integer, object, array, etc).
|
killCursors
. Cursors are associated with the users at the time of cursor creation.killCursors
privilege to kill their own cursors. Cursors are associated with the users at the time of cursor creation.If a user possesses the killAnyCursor
privilege, that user may kill any cursor, even cursors created by other users.
killCursors
and Transactions¶Starting in MongoDB 4.2, you cannot specify killCursors
as the first operation in a transaction.
Consider the following find
operation on the test.restaurants
collection:
which returns the following:
To kill this cursor, use the killCursors
command.
killCursors
returns the following operation details: