Aggregation Query
POST/collections/:collectionName/documents/aggregations
Perform complex data analysis using MongoDB native aggregation pipelines. Supported stages include: $match, $group, $project, $sort, $limit, $skip, $unwind, $lookup (admin permissions only), $addFields, $count, $sample, $bucket, $bucketAuto, $geoNear, $replaceRoot, $sortByCount.
Auto-limits: $limit: 20 is automatically added when not specified. Under PRIVATE permissions, $match: {_openid: "xxx"} is automatically added.
Request
Path Parameters
collectionName stringrequired
Collection name
- application/json
Body
required
pipeline object[]required
MongoDB native aggregation pipeline array, each element is an EJSON object containing a single aggregation stage
Responses
- 200
- 400
Aggregation query successful
- application/json
- Schema
- Example (from schema)
- group
- count
Schema
list object[]
Aggregation result list (EJSON format)
{
"list": [
{}
]
}
Grouping statistics result
{
"list": [
{
"_id": "Beijing",
"count": 150
},
{
"_id": "Shanghai",
"count": 120
}
]
}
Count result
{
"list": [
{
"activeCount": 42
}
]
}
Invalid request parameters
- application/json
- Schema
- Example (from schema)
Schema
code string
Error code
message string
Error message
request_id string
Unique request ID
{
"code": "INVALID_PARAM",
"message": "param.query can't be empty",
"request_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
Loading...