POST / 动作/updateOne
curl -s "https://data.mongodb-api.com/app/$CLIENT_APP_ID/endpoint/data/v1/action/updateOne" \
-X POST \
-H "apiKey: $API_KEY" \
-H 'Content-Type: application/ejson' \
-H "Accept: application/json" \
-d '{
"dataSource": "mongodb-atlas",
"database": "learn-data-api",
"collection": "tasks",
"filter": {
"_id": { "$oid": "64224f4d089104f1766116a5" }
},
"update": {
"$set": {
"status": "complete",
"completedAt": { "$date": { "$numberLong": "1680105272788" } }
}
}
}'
请求示例
{
"filter": {
"_id": {
"$oid": "642f1bb5cee4111898828bf6"
}
},
"update": {
"$set": {
"status": "complete"
}
},
"upsert": false,
"database": "todo",
"collection": "tasks",
"dataSource": "mongodb-atlas"
}
请求示例
{
"filter": {
"_id": {
"$oid": "642f1bb5cee4111898828bf6"
}
},
"update": {
"$set": {
"status": "complete"
}
},
"upsert": false,
"database": "todo",
"collection": "tasks",
"dataSource": "mongodb-atlas"
}
响应示例 (200)
{
"matchedCount": 1,
"modifiedCount": 1
}
响应示例 (200)
{
"matchedCount": {
"$numberInt": "1"
},
"modifiedCount": {
"$numberInt": "1"
}
}
响应示例 (400)
Errornoauthenticationspecified
{
"error": "no authentication methods were specified",
"error_code": "InvalidParameter",
"link": "string"
}
{
"error": "must specify some form of authentication (either email+password, api-key, or jwt) in the request header or body",
"error_code": "MissingParameter",
"link": "string"
}
响应示例 (401)
{
"error": "invalid session: error finding user for endpoint",
"error_code": "InvalidSession",
"link": "string"
}