$comment

$comment

Deprecated since v3.2

Starting in v3.2, the $comment operator is deprecated in the mongo shell. 从v3.2开始,$comment运算符在mongo shell中不受欢迎。In the mongo shell, use cursor.comment() instead.mongo shell中,请改用cursor.comment()

The $comment meta-operator makes it possible to attach a comment to a query in any context that $query may appear.$comment元运算符可以在$query可能出现的任何上下文中向查询附加注释。

Because comments propagate to the profile log, adding a comment can make your profile data easier to interpret and trace.由于注释会传播到profile日志中,因此添加注释可以使配置文件数据更易于解释和跟踪。

Use $comment in one of the following ways:通过以下方式之一使用$comment

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.将注释附加到其他上下文(如db.collection.update())中的查询表达,请使用$comment查询运算符而不是元运算符。

See also参阅

$comment query operator