Execute Database Commands
POST/commands
Execute MongoDB native database commands in batch. All commands are executed sequentially and return a corresponding result array. Supports transaction execution.
Only administrator permissions can invoke this endpoint.
Common commands include: find, insert, update, delete, aggregate, createIndexes, etc.
Request
- application/json
Body
required
commands object[]required
Array of MongoDB native commands, each element is an EJSON object
transactionId string
Transaction ID (execute all commands within the transaction)
Responses
- 200
- 400
Commands executed successfully
- application/json
- Schema
- Example (from schema)
- Example
Schema
list array[]
2D EJSON array, list[i] corresponds to the result of commands[i]
{
"list": [
[
{}
]
]
}
{
"list": [
[
{
"cursor": {
"firstBatch": [
{
"_id": {
"$oid": "507f1f77bcf86cd799439011"
},
"name": "John",
"age": {
"$numberInt": "30"
}
}
],
"id": {
"$numberLong": "0"
},
"ns": "db.users"
},
"ok": {
"$numberInt": "1"
}
}
]
]
}
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...