Actions12
- Search Index Actions
- Document Actions
Document → Find And Replace
AI-generatedSummary
Replace a document matching a filter, optionally upserting and returning the modified version.
Inputs
- collection (required) — MongoDB collection to operate on
- document (required) — Document to insert or update; when Many is enabled, an array of documents
- updateFilter (required) — Filter specifying which document(s) to update
- upsert — Whether to insert a document if no match for the update filter
- options — Operation‑specific options such as timeout, maxTimeMS, hint, arrayFilters, and returnDocument
Output shape
a list of modified documents
One result per input item; fields vary by operation and may include error objects when continueOnFail is enabled.
Examples
Example 1: Insert or replace a single document
collection: "users", document: {"name":"Alice","age":30}, upsert: false, options: {"returnDocument":"after"}
Example 2: Update a user document with upsert
collection: "users", updateFilter: {"name":"Bob"}, document: {"$set":{"age":31}}, upsert: true, options: {"returnDocument":"after"}
Example 3: Perform an update with arrayFilters
collection: "orders", updateFilter: {"orderId":"123"}, update: {"$set":{"status":"shipped"}}, options: {"arrayFilters":[{"elem.status":"pending"}]}