执行数据库命令
POST/commands
批量执行 MongoDB 原生数据库命令。所有命令按顺序执行,返回对应的结果数组。支持在事务中执行。
仅管理员权限可以调用。
常用命令包括:find、insert、update、delete、aggregate、createIndexes 等。
Request
- application/json
Body
required
commands object[]required
MongoDB 原生命令数组,每个元素是一个 EJSON 对象
transactionId string
事务 ID(在事务中执行所有命令)
Responses
- 200
- 400
命令执行成功
- application/json
- Schema
- Example (from schema)
- Example
Schema
list array[]
二维 EJSON 数组,list[i] 对应 commands[i] 的执行结果
{
"list": [
[
{}
]
]
}
{
"list": [
[
{
"cursor": {
"firstBatch": [
{
"_id": {
"$oid": "507f1f77bcf86cd799439011"
},
"name": "John",
"age": {
"$numberInt": "30"
}
}
],
"id": {
"$numberLong": "0"
},
"ns": "db.users"
},
"ok": {
"$numberInt": "1"
}
}
]
]
}
请求参数错误
- 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...