update-many
Update all documents that match a filter in a MongoDB collection, applying update operators to multiple records in one operation. Include upsert to insert if no match.
Instructions
Updates all documents that match the specified filter for a collection. If the list of documents is above com.mongodb/maxRequestPayloadBytes, consider updating them in batches.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"database": "<database>",
"collection": "<collection>",
"update": "<update>"
},
"name": "update-many"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | The selection criteria for the update, matching the syntax of the filter argument of db.collection.updateOne() | |
| update | Yes | An update document describing the modifications to apply using update operator expressions | |
| upsert | No | Controls whether to insert a new document if no documents match the filter | |
| database | Yes | Database name | |
| collection | Yes | Collection name |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | Yes | ||
| collection | Yes | ||
| upsertedId | No | ||
| matchedCount | Yes | ||
| modifiedCount | Yes | ||
| upsertedCount | Yes |