Create Row

The Create Row step allows you to create a row in a table.

{{ui.form.value}}

Sending data as an object

By default, the expected format is an object that represents the row to be created. The object keys are the column names and the values are the values to be inserted.

{
  name: "John",
  age: 30
}

This object will be sent to the server and converted to an INSERT statement, for example:

INSERT INTO users (name, age) VALUES ('John', 30)

You can check the action's Payload tab to see the actual object sent to the server.

Unset fields will be presented as undefined and will not be used in the INSERT statement - the table defaults will be applied instead.

{
  id: 23,
  created_at: "2022-10-21",
  // this value will not be sent to the server
  required_at: undefined,
}

You can always adjust the data before sending it.

Adding additional values

const values = {{ui.form.value}};

return {
  ...values,
  created_at: new Date(),
}

Changing values

const values = {{ui.form.value}};
return {
  ...values,
  name: values.name.toUpperCase(),
}

Deleting unnecessary values

const values = {{ui.form.value}};
delete values.age;
return values;

or:

const values = {{ui.form.value}};
const { created_at, ...rest } = values;
return rest;

Joining array values

const values = {{ui.form.value}};
return {
  ...values,
  tags: values.tags.join(','),
}

Using default values

const values = {{ui.form.value}};
return {
  ...values,
  // if the value is not set, use the default value
  created_at: values.created_at || new Date(),
}

Sending data field by field

You can also send the data field by field by clicking the JS button on the right of the Configure Row section. This way, you'll switch to the UI mode where you can specify each column separately.

{{ui.input.value}}
  • Specify default values:

{{ui.input.value || new Date()}}
  • Trim spaces:

{{ui.input.value.trim()}}

Last updated

Was this helpful?