On this page本页内容
You can use the 您可以将$comment
with any expression taking a query predicate, such as the query predicate in db.collection.update()
or in the $match
stage of the aggregation pipeline.$comment
与任何接受查询谓词的表达式一起使用,例如db.collection.update()
中的查询谓词或聚合管道的$match
阶段中的查询谓词。For an example, see Attach a Comment to an Aggregation Expression.有关示例,请参阅将注释附加到聚合表达式。
find
find
¶The following example adds a 以下示例将$comment
to a find()
operation:$comment
添加到find()
操作中:
If the Database Profiler is enabled, the following output shows the comment in the 如果启用了数据库探查器,则以下输出将显示system.profile
collection:system.profile
集合中的注释:
Comments also appear in the MongoDB log if the database profiler level is set to 2 and slowms is set to 0ms.如果数据库探查器级别设置为2且slowms设置为0ms,则注释也会出现在MongoDB日志中。This 此db.setProfilingLevel()
command sets these two parameters:db.setProfilingLevel()
命令设置以下两个参数:
The comment for the previous 前面的db.records.find()
example then appears as follows in the MongoDB log:db.records.find()
示例的注释随后出现在MongoDB日志中,如下所示: