$comment
MongoDB 5.0 is end of life as of October 2024. This version of the documentation is no longer
supported. To upgrade your 5.0 deployment, see the MongoDB 6.0 upgrade procedures.
$comment
Note
Deprecated since v3.2
Starting in v3.2, the
$comment
operator is deprecated inmongosh
. Inmongosh
, usecursor.comment()
instead.The
$comment
meta-operator makes it possible to attach a comment to a query in any context that$query
may appear.Because comments propagate to the
profile
log, adding a comment can make your profile data easier to interpret and trace.Use
$comment
in one of the following ways:db.collection.find( { <query> } )._addSpecial( "$comment", <comment> ) db.collection.find( { <query> } ).comment( <comment> ) db.collection.find( { $query: { <query> }, $comment: <comment> } ) To attach comments to query expressions in other contexts, such as
db.collection.update()
, use the$comment
query operator instead of the meta-operator.