批量更新文档
PATCH/collections/:collectionName/documents
根据查询条件批量更新文档。支持 MongoDB 更新操作符(如 $set、$inc、$push 等)。
当 replaceMode 为 false(默认)且 data 中不包含更新操作符时,会自动包装为 $set 操作。
不允许修改 _openid 和 _id 字段。
Request
Path Parameters
collectionName stringrequired
集合名称
- application/json
Body
required
query objectrequired
查询条件(EJSON 对象)
data objectrequired
更新数据(EJSON 对象),支持更新操作符
multi boolean
是否批量更新
upsert boolean
不存在时是否创建
replaceMode boolean
是否替换整个文档(为 true 时替换整个文档,为 false 时合并更新)
transactionId string
事务 ID
Responses
- 200
- 400
更新成功
- application/json
- Schema
- Example (from schema)
- Example
Schema
updated integer
更新的文档数量
matched integer
匹配的文档数量
upsert_id string
upsert 创建的文档 ID(如有)
{
"updated": 0,
"matched": 0,
"upsert_id": "string"
}
{
"updated": 1,
"matched": 1,
"upsert_id": ""
}
请求参数错误
- 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...