Query Modifiers查询修饰符
In addition to the MongoDB Query Operators, there are a number of “meta” operators that let you modify the output or behavior of a query.除了MongoDB查询运算符外,还有许多“元”操作符,可用于修改查询的输出或行为。
Note
Deprecated in the mongo
Shell since v3.2从v3.2开始,mongo
Shell中已弃用
Starting in v3.2, the query “meta” operators are deprecated in the mongo
shell. 从v3.2开始,mongo
shell中不推荐使用查询“meta”运算符。In the mongo
shell, use the cursor methods instead.在mongo
shell中,改用游标方法。
The driver interfaces may provide cursor methods that wrap these options. 驱动程序接口可能提供包装这些选项的游标方法。When possible, use these methods; otherwise, you can add these options using either of the following syntax:如果可能,使用这些方法;否则,可以使用以下语法之一添加这些选项:
Operators运算符
Modifiers修饰语
Note
Deprecated in the mongo
Shell since v3.2从v3.2开始,mongo
Shell中已弃用
Starting in v3.2, the query “meta” operators are deprecated in the mongo
shell. 从v3.2开始,mongo
shell中不推荐使用查询“meta”运算符。In the mongo
shell, use the cursor methods instead.在mongo
shell中,改用游标方法。
Name名称 | Description描述 |
$comment |
Adds a comment to the query to identify queries in the database profiler output.向查询添加注释,以标识数据库探查器输出中的查询。 |
$explain |
Forces MongoDB to report on query execution plans. 强制MongoDB报告查询执行计划。See explain() .参阅explain() 。 |
$hint |
Forces MongoDB to use a specific index. 强制MongoDB使用特定索引。See hint() 参阅hint() 。 |
$max |
Specifies an exclusive upper limit for the index to use in a query. 指定要在查询中使用的索引的排除性上限。See max() .参阅max() 。 |
$maxTimeMS |
Specifies a cumulative time limit in milliseconds for processing operations on a cursor. 指定处理光标上的操作的累积时间限制(以毫秒为单位)。See maxTimeMS() .参阅maxTimeMS() 。 |
$min |
Specifies an inclusive lower limit for the index to use in a query. 指定要在查询中使用的索引的包含性下限。See min() .参阅min() 。 |
$orderby |
Returns a cursor with documents sorted according to a sort specification. 返回一个游标,其中包含根据排序规范排序的文档。See sort() .参阅sort() 。 |
$query |
Wraps a query document.包装查询文档。 |
$returnKey |
Forces the cursor to only return fields included in the index.强制光标仅返回索引中包含的字段。 |
$showDiskLoc |
Modifies the documents returned to include references to the on-disk location of each document.修改返回的文档,以包括对每个文档的磁盘上位置的引用。 |
Sort Order排序顺序
Name名称 | Description描述 |
$natural |
A special sort order that orders documents using the order of documents on disk.使用磁盘上文档的顺序对文档进行排序的特殊排序顺序。 |