killCursors
On this page
New in version 3.2.
Definition
-
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:
Field Type Description killCursors
string The name of the collection. cursors
array The ids of the cursors to kill.
Required Access
Changed in version 3.6.3.
To successfully execute a killCursors
command, all cursors that you wish to kill must be associated with a currently authenticated user. MongoDB associates cursors with the users that were authenticated when the cursor was created. If the operation is not successful due to permission issues, the command returns an error message.
Alternatively, if a user possesses the killAnyCursor
privilege, that user may kill any cursor regardless of what users the cursor is associated with.
Example
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: