On this page本页内容
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()方法具有以下语法:
db.aggregate( [ <pipeline> ], { <options> } )
pipeline parameter is an array of stages to execute. pipeline参数是要执行的阶段数组。$currentOp or $listLocalSessions.$currentOp或$listLocalSessions。The 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 |
| |
bypassDocumentValidation | boolean |
|
readConcern | document |
|
collation | document |
collation: {
locale: <string>,
caseLevel: <boolean>,
caseFirst: <string>,
strength: <int>,
numericOrdering: <boolean>,
alternate: <string>,
maxVariable: <string>,
backwards: <boolean>
}
|
hint | string or document |
|
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操作,第二阶段筛选该操作的结果。
use admin
db.aggregate( [ {
$currentOp : { allUsers: true, idleConnections: true } }, {
$match : { shard: "shard01" }
}
] )