Query Document List
GET/collections/:collectionName/documents
Query documents in a collection. Supports complex query conditions (MongoDB query syntax), pagination, sorting, and field projection.
When count=true, only returns the count of matching documents without the document list.
Request
Path Parameters
Collection name
Query Parameters
Default value: {}
Query conditions (EJSON string), e.g. {"age":{"$gte":18}}
Default value: 0
Offset for pagination
Default value: 20
Number of documents per page
Sort rules (JSON string), e.g. [{"field":"age","direction":"desc"}]
Field projection (JSON string), e.g. {"name":1,"email":1}
Set to true to return only the document count
Transaction ID
Responses
- 200
- 400
Query successful
- application/json
- Schema
- Example (from schema)
- list
- count
Schema
- MOD1
- MOD2
Current offset
Documents per page
Document list (EJSON format)
Total number of matching documents
{}
{
"offset": 0,
"limit": 20,
"list": [
{
"_id": {
"$oid": "507f1f77bcf86cd799439011"
},
"name": "John Doe",
"age": {
"$numberInt": "30"
}
}
]
}
{
"total": 42
}
Invalid request parameters
- application/json
- Schema
- Example (from schema)
Schema
Error code
Error message
Unique request ID
{
"code": "INVALID_PARAM",
"message": "param.query can't be empty",
"request_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}