All nodes/Data/Database

DB Update

Updates documents matching the filter with a MongoDB-style update expression ($set, $inc, $push, ...). Supports upsert and multi.

DB Update
InputResult

Type in the graph: db_update

Exec

An error branch can be enabled (expose_error_output) to handle failures on their own path.

Ports can be split into separate execution and data handles.

Try it

Minimal working workflow

Entry
DB Update
Exit
  • Execute + Data
Press “Copy nodes”, open the editor and hit Ctrl+V on the canvas.

Runs as pasted

When to use it

Update changes existing documents: move a ticket to another status, bump a counter, append an item to an array. With Upsert on it becomes “create or update” — the only way to write a document by key so that a repeated run leaves no duplicate (db_insert has no such check). The Update many flag switches the node from one document to every match.

How it works

Two expressions are needed: Filter picks the documents, Update says what to do with them ($set, $inc, $push, $unset, $addToSet and other operators). The Input port accepts an envelope {"filter": …, "update": …}, in which case both halves arrive over the edge; any other object is treated as the filter and the update expression stays as configured.

The output has three fields: matched (how many documents the filter picked), modified (how many actually changed) and upserted_id (the id of the document created when an upsert fired).

Common mistakes

  • An expression with no operator. {"status": "paid"} without $set is not a field edit but a whole-document replacement: the other fields disappear and only _id survives. Write {"$set": {"status": "paid"}}.
  • Judging success by modified. Zero there does not only mean “nothing matched”: a document that already holds the value is not rewritten, and an upsert also leaves the counter at zero — the new document shows up in upserted_id. Read all three fields.
  • Forgetting to switch on “Update many”. With the flag off exactly one of the matching documents changes, and which one is undefined.
  • Expecting upsert to carry the whole filter into the new document. Only plain top-level equalities are seeded; conditions such as {"$gt": …} and dotted paths are not — set those fields explicitly in $set.
  • Templates in the fields. Filter and Update are JSON editors; {{ … }} is not expanded there. Build the dynamic part with code_javascript or a template and feed it to the port.
  • $inc on a non-numeric field. If the field holds a string the node fails; coerce the type when you write it.

Inputs

PortWirePayloadNotes
InputinputExecute + Dataexecute_data

Run trigger and dynamic payload (overrides static config). The payload must be an object — a value of any other shape fails the node instead of being ignored.

Outputs

PortWirePayloadNotes
ResultoutputExecute + Dataexecute_dataobject

Configuration

FieldTypeDefaultDescription
Collectioncollection_idstring""

Collection ID

Filterfilterobject

Update manymultibooleanfalse

Updateupdateobject

MongoDB-style update expression ($set, $inc, $push, ...).

Upsertupsertbooleanfalse

Shared fields

Every node has these three — the platform adds them, not the node author.

  • expose_error_output — When enabled, show an execution output to connect nodes that run if this step fails.
  • split_ports_in — Show separate execution and data input handles instead of one combined port.
  • split_ports_out — Show separate execution and data output handles instead of one combined port.