参考 > 参考 > 经营者 > 查询和投影运算符 > $评论
在本页面
$comment
该$comment查询操作关联采取查询谓词的任何表达意见。
由于注释会传播到profile日志,因此添加注释可以使您的个人资料数据更易于解释和跟踪。
profile
该$comment运营商的形式为:
db.collection.find( { <query>, $comment: <comment> } )
您可以将_ $comment与任何带查询谓词的表达式一起使用,例如聚合管道中db.collection.update()或聚合$match阶段中的查询谓词 。有关示例,请参见对聚合表达式附加注释。
db.collection.update()
$match
find
以下示例$comment向 find()操作添加:
find()
db.records.find( { x: { $mod: [ 2, 0 ] }, $comment: "Find even values." } )
您可以对$comment带查询谓词的任何表达式使用。
以下示例$comment在$match阶段中使用运算符 来阐明操作:
db.records.aggregate( [ { $match: { x: { $gt: 0 }, $comment: "Don't allow negative inputs." } }, { $group : { _id: { $mod: [ "$x", 2 ] }, total: { $sum: "$x" } } } ] )
也可以看看