# Add a row to a table

> Adds the details found as a row in one of your tables, or updates the row with the same key.

Source: https://docs.go-lumen.ai/de/reference/steps/add-row

## Auf einen Blick

| Eigenschaft | Wert |
| --- | --- |
| **Schrittname** | `add-row` |
| **Ressource** | ClusterStep (`lumen.ai/v1alpha1`) |
| **Palettengruppe, Kategorie** | save, tables |
| **Credits** | **1** Credit bei jedem Erfolg |
| **Externe Wirkung** | ja: Er ändert etwas außerhalb von Lumen, deshalb fragt ein Wiederholungsversuch vorher nach, und ein Test zeigt, was er tun würde, statt es zu tun. |
| **Die Installation muss bereitstellen** | nichts |

## Eingaben

| Eigenschaft | Wert |
| --- | --- |
| **Braucht** | `fields` |
| **Liefert** | `fields` |
| **Arbeitet auf** | item: einem Dokument nach dem anderen |

Braucht und Liefert sind Datentypen (file, text, fields, email). Der Editor bietet einen Schritt nur dort an, wo das, was er braucht, schon auf dem Pfad liegt. Siehe [Dokumente und Daten](https://docs.go-lumen.ai/de/concepts/how-flows-run.md#documents-and-data).

## Ausgaben

Ein späterer Knoten verweist auf eine Ausgabe als `{nodeId.field}` in einem Text oder als `nodeId.field` in einer Bedingung.

| Ausgabe | Typ |
| --- | --- |
| `rowId` | string |
| `rowCreated` | boolean |

## Einstellungen

Wird unter `config:` im Knoten des Flows gesetzt. Texteinstellungen dürfen Platzhalter wie `{nodeId.field}` enthalten.

| Einstellung | Typ | Standardwert | Beschreibung |
| --- | --- | --- | --- |
| `sheet` (erforderlich) | string |  | Name of the table to add the row to. (minLength 1) |
| `base` | string |  | Name of the base (database) the table is in. Optional: when set, the table must belong to this base. (minLength 1) |
| `mapping` | map of string |  | Mapping says what goes in each column: a column name to "`{field}`" (that field's value), or to text with `{placeholders}` in it, or to a plain value. A column left out takes the field of the same name. |
| `mode` | string | `"insert"` | Mode is insert (the default: always a new row) or upsert (set the values on the row with the same key, or add one; the Sheet needs a key). (one of insert, upsert) |

Das vollständige JSON Schema dieser Einstellungen: [add-row.schema.json](https://docs.go-lumen.ai/schemas/steps/add-row.schema.json).

## Beispiel

```yaml title="config"
mapping:
  city: '{city}'
  contact: '{contact}'
  name: '{name}'
  status: '{status}'
mode: insert
sheet: Suppliers
```

## Im Flow verwenden

Ein Knoten, der `add-row` ausführt, steht unter `spec.nodes` eines [Flow](https://docs.go-lumen.ai/de/concepts/how-flows-run.md#the-flow-as-yaml). Geben Sie ihm eine beliebige id und nennen Sie in next die ids der nächsten Knoten.

```yaml title="flow.yaml"
apiVersion: lumen.ai/v1alpha1
kind: Connector
metadata:
  name: my-webhook
  namespace: tenant-acme
spec:
  classRef: {name: webhook}
  config: {}
---
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
  name: add-row-example
  namespace: tenant-acme
spec:
  displayName: "Add a row to a table"
  triggers:
    - id: start
      ref: {name: webhook-received}
      connectorRef: {name: my-webhook}
      next: [add-row]
  nodes:
    - id: add-row
      stepRef: {name: add-row}
      config:
        mapping:
          city: '{city}'
          contact: '{contact}'
          name: '{name}'
          status: '{status}'
        mode: insert
        sheet: Suppliers
```
