On this page本页内容
New in version 3.6.版本3.6中的新功能。
db.aggregate()¶Runs a specified admin/diagnostic pipeline which does not require an underlying collection. 运行不需要基础集合的指定管理/诊断管道。For aggregations on collection data, see 有关收集数据的聚合,请参阅db.collection.aggregate().db.collection.aggregate()。
The db.aggregate() method has the following syntax:db.aggregate()方法语法如下所示:
pipeline parameter is an array of stages to execute. pipeline参数是要执行的阶段数组。$currentOp or $listLocalSessions.$currentOp或$listLocalSessions。options document can contain the following fields and values:options文档可以包含以下字段和值:
explain |
boolean |
|
allowDiskUse |
boolean |
|
cursor |
document | cursor field is a document with the field batchSize. cursor字段的值是具有batchSize字段的文档。 |
maxTimeMS |
non-negative integer |
|
bypassDocumentValidation |
boolean |
|
readConcern |
document |
|
collation |
document |
Collation
|
hint |
string or document |
Note The
|
comment |
string |
|
writeConcern |
document |
|
$currentOp$currentOp的管道¶The following example runs a pipeline with two stages. 下面的示例运行一个包含两个阶段的管道。The first stage runs the 第一阶段运行$currentOp operation and the second stage filters the results of that operation.$currentOp操作,第二阶段筛选该操作的结果。