Create Row

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

{{ui.form.value}}

Send 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 like this:

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

Note: you can check the Payload section to see the actual object sent to the server.

Note: the unset fields will be presented as undefined and will not be used in the INSERT statement, so that the table defaults will be applied

{
  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.

Add additional values

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

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

The created_at column must exist in the table schema, otherwise it will not be sent.

Change the values

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

Delete unwanted values

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

alternatively:

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

Join array values

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

Use 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(),
}

Send data field by field

If you'd like to send the data field by field, you can switch the field from the JS mode to a UI mode by clicking on the JS button above the right corner of the field.

In this case, 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

© 2024 UI Bakery