Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

data_write

The write counterpart of data_query: one backend-neutral mutationinsert, update, delete, or upsert — rendered natively for SQL, MongoDB, or Elasticsearch. The filter of an update/delete is the query dialect’s filter, unchanged. See the Portable Data Dialect reference for the full envelope, backend mapping, and safety rules.

Synopsis

{
  "name": "data_write",
  "input": {
    "connector": "orders-db",
    "write": {},
    "params": {
      "id": {
        "var": "data.order_id"
      }
    },
    "schema": {},
    "database": "…",
    "numeric_as": "number",
    "binary_as": "auto",
    "output": "data.write_result"
  }
}

Description

data_write is a connector function. It names a connector for its credentials and endpoint. Orion validates its input when the workflow is saved, and the call runs through the connector’s circuit breaker.

Retry safety: depends_on op. See Retry safety for what the answer costs.

Fields

FieldTypeRequiredDefaultDescription
connectorstringyesName of a db or es connector
writeobjectyesThe mutation envelope — fields below
paramsobjectno{}Named values referenced as { "param": "name" } inside values, set, and filter; each value is JSONLogic resolved against the context
schemaobjectyesInline entity schema: renames, allowlist, writable flags. Undeclared entities and columns are rejected; {"unmapped": "identity"} accepts undeclared names as physical ones. Enforced at run time, like data_query’s
databasestringconditionalDatabase name; required when the connector is MongoDB (checked at workflow activation), unused otherwise
numeric_asstringno"number"How a numeric/decimal column is rendered: number or string — see Decimal columns. SQL backends only
binary_asstringno"auto"How a binary column is rendered: auto, hex, base64 or text — see Binary columns. SQL backends only
outputstring | JSONLogicno"data"Dotted path where the write result is written

Inside write:

FieldTypeRequiredDefaultDescription
opstringyesinsert | update | delete | upsert
targetstringyesLogical entity → table / collection / index
valuesobject | arrayconditionalThe row object or objects to insert; required for insert and upsert
setobjectconditionalColumn → value/param assignments; required for update, optional overrides on upsert conflict
filterJSONLogicconditionalRow selection for update/delete (same operators as data_query); required unless the unfiltered opt-in below is used
on_conflictobjectconditional{ "target": [cols], "action": "update" | "nothing" }; required for upsert
returningarraynoColumns returned from mutated rows (PostgreSQL/SQLite only)
allboolnofalseAcknowledge an intentionally unfiltered update/delete

Examples

{
  "name": "data_write",
  "input": {
    "connector": "orders-db",
    "params": { "id": { "var": "data.order_id" } },
    "schema": {
      "entities": {
        "orders": {
          "columns": {
            "id": { "type": "int", "writable": false }, "status": { "type": "text" }
          }
        }
      }
    },
    "output": "data.write_result",
    "write": {
      "op": "update",
      "target": "orders",
      "set": { "status": "shipped" },
      "filter": { "==": [{ "field": "id" }, { "param": "id" }] }
    }
  }
}

Safety guards: unfiltered mutations are rejected unless "all": true and write.allow_unfiltered are both set, and bulk inserts over write.max_rows are rejected. A connector’s operation gates can disable individual ops entirely. Results are normalized per backend. SQL returns { "status": "ok", "rows_affected": n }, plus returning / last_insert_id where supported. MongoDB and Elasticsearch return doc-store counts (inserted/ids, matched/modified, deleted). Every result carries a status; a bulk insert that applied only some of its rows reports "partial" with a per-item array. See Bulk writes.

Last verified 14 September 2026