查询文档列表
GET/collections/:collectionName/documents
查询集合中的文档列表,支持复杂查询条件(MongoDB 查询语法)、分页、排序和字段过滤。
当 count=true 时,仅返回符合条件的文档数量,不返回文档列表。
Request
Path Parameters
collectionName stringrequired
集合名称
Query Parameters
query string
Default value: {}
查询条件(EJSON 字符串),如 {"age":{"$gte":18}}
offset integer
Default value: 0
偏移量(分页)
limit integer
Default value: 20
每页数量
order string
排序规则(JSON 字符串),如 [{"field":"age","direction":"desc"}]
projection string
字段过滤(JSON 字符串),如 {"name":1,"email":1}
count boolean
设置为 true 时仅返回文档数量
transactionId string
事务 ID
Responses
- 200
- 400
查询成功
- application/json
- Schema
- Example (from schema)
- list
- count
Schema
- MOD1
- MOD2
oneOf
offset integer
当前偏移量
limit integer
每页数量
list object[]
文档列表(EJSON 格式)
total integer
符合条件的文档总数
{}
文档列表
{
"offset": 0,
"limit": 20,
"list": [
{
"_id": {
"$oid": "507f1f77bcf86cd799439011"
},
"name": "John Doe",
"age": {
"$numberInt": "30"
}
}
]
}
统计数量(count=true)
{
"total": 42
}
请求参数错误
- application/json
- Schema
- Example (from schema)
Schema
code string
错误码
message string
错误信息
request_id string
请求唯一 ID
{
"code": "INVALID_PARAM",
"message": "param.query can't be empty",
"request_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
Loading...