Batch Update Documents
PATCH/collections/:collectionName/documents
Update documents matching the query conditions. Supports MongoDB update operators (e.g. $set, $inc, $push, etc.).
When replaceMode is false (default) and data does not contain update operators, it will be automatically wrapped with $set.
Modifying _openid and _id fields is not allowed.
Request
Path Parameters
collectionName stringrequired
Collection name
- application/json
Body
required
query objectrequired
Query conditions (EJSON object)
data objectrequired
Update data (EJSON object), supports update operators
multi boolean
Whether to update multiple documents
upsert boolean
Whether to create if not exists
replaceMode boolean
Whether to replace the entire document (true = replace, false = merge update)
transactionId string
Transaction ID
Responses
- 200
- 400
Update successful
- application/json
- Schema
- Example (from schema)
- Example
Schema
updated integer
Number of updated documents
matched integer
Number of matched documents
upsert_id string
ID of the upserted document (if any)
{
"updated": 0,
"matched": 0,
"upsert_id": "string"
}
{
"updated": 1,
"matched": 1,
"upsert_id": ""
}
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...