DB: Insert Batch (header + children, atomic)

db_insert_batch · action · Database · Available · v1.1.0

Description

ATOMICALLY insert a header (e.g. order) + N child rows (e.g. order_lines), all in a single transaction. If inserting the lines fails, the header is rolled back too — no phantom orders in DB. Typical for: orders+order_lines, invoices+invoice_lines, deliveries+delivery_items.

⚙️ Configuration parameters

Fields shown in the editor when configuring the node. Generated directly from the NodeDefconfigFields.

FieldTypeRequiredDefaultDescription
databaseId
Database
db-pickeryes
headerTable
Tabella header
db-table-pickeryesEs. "orders". 1 riga inserita.
headerRowJson
Header row (JSON)
codeyes
{ "order_number": "{{input.order_number}}", "supplier_code": "{{input.supplier_code}}" }
JSON object con le colonne dell'header. Espressioni {{}} risolte runtime.
childTable
Tabella children
db-table-pickeryesEs. "order_lines". N righe inserite.
childRowsExpression
Espressione array children
expressionyes
input.lines
Espressione JS che ritorna l'array di righe figlie. Esempi: input.lines · input.order_lines · output.items. Riceve `input` (output del nodo precedente).
refColumn
Colonna FK (children → header)
stringyes
order_id
Nome della colonna sul child che riferisce l'id dell'header. Es. "order_id" se order_lines.order_id REFERENCES orders.id.
onConflict
Se l'header esiste già
enum
failignore
nofail"fail" (default): se l'header viola un UNIQUE/PK, errore (utile per accorgersi di duplicati indesiderati). "ignore": se l'header esiste già, salta l'intero batch atomico e ritorna { alreadyExisted: true } — utile per workflow ricevuti più volte sullo stesso input (es. webhook con retry, email duplicate).
skipColumns
Colonne da NON inserire (comma-separated)
stringnoline_total,net_price,price_discrepancy_flagLista di nomi colonna da rimuovere prima del INSERT. Tipicamente colonne GENERATED in DB SQL (es. line_total REAL GENERATED ALWAYS AS qty*price*(1-discount)) che il DB rifiuta di accettare in INSERT. Default coprono il 90% dei casi italian-procurement. Aggiungere/togliere secondo schema reale del tuo DB.

💡 Configuration example

JSON snippet of the node as it appears in the workflow. Values are derived fromdefaultValue and from required parameters.

{
  "id": "node-db_insert_batch-1",
  "defId": "db_insert_batch",
  "label": "DB: Insert Batch (header + children, atomic)",
  "config": {
    "databaseId": "<databaseId>",
    "headerTable": "<headerTable>",
    "headerRowJson": "{\n  \"order_number\": \"{{input.order_number}}\",\n  \"supplier_code\": \"{{input.supplier_code}}\"\n}",
    "childTable": "<childTable>",
    "childRowsExpression": "input.lines",
    "refColumn": "order_id",
    "onConflict": "fail",
    "skipColumns": "line_total,net_price,price_discrepancy_flag"
  }
}

🔗 Related nodes in the same category

Ready to use DB: Insert Batch (header + children, atomic)?

Available now on all FlowForge plans. Try it free without a credit card.

Start freeBrowse all nodes