This version of the documentation is archived and no longer
supported. View the current documentation to learn how to
upgrade your version of MongoDB.
$commentNote
Deprecated since v3.2
Starting in v3.2, the
$commentoperator is deprecated in themongoshell. In themongoshell, usecursor.comment()instead.The
$commentmeta-operator makes it possible to attach a comment to a query in any context that$querymay appear.Because comments propagate to the
profilelog, adding a comment can make your profile data easier to interpret and trace.Use
$commentin 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$commentquery operator instead of the meta-operator.
Tip
$comment query operator