New in version 3.6.
$currentOpoffers a better alternative to the
currentOpcommand and the
db.currentOpmethod. The latter two commands are limited to returning all operations in a single document, which must not exceed the maximum 16MB BSON size. Since
$currentOppipelines return a cursor, they are not subject to these limitations.
$currentOpalso enables you to perform arbitrary transformations of the results as the documents pass through the pipeline.
$currentOptakes an options document as its operand.
Specify an empty document to use the default values.
Boolean. If set to
$currentOpmust be the first stage in the pipeline.
- Pipelines that start with
$currentOpcan only be run on the
- On a standalone or replica set with authentication enabled, the
inprogprivilege is required to run
allUsersparameter is set to true.
- On a sharded cluster, the
inprogprivilege is required to run all
The following example runs the
$currentOp operation in the first stage and filters the results of that operation in the second stage.