SurrealDB icon

SurrealDB

Interaction with a SurrealDB database

Field → Create Field

AI-generated

Summary

Create a new field in a specified table within SurrealDB, configuring its name, type, mode, and additional options such as default value, validation assertion, and read-only status.

Inputs

  • Table (required) — The name of the table on which to create the field.
  • Field Name (required) — The name of the field to create.
  • Field Mode — Specifies whether the field stores data directly ('Standard') or is computed from an expression ('Computed').
  • Field Type — Data type of the field, such as string, int, bool, etc.
  • Record Table Type — If the field type is 'Record', specifies the type of record that the field can reference.
  • Computation Expression — SurrealQL expression to compute the value of the field; used only when the field mode is 'Computed'.
  • Is Flexible — Determines if the field accepts any data type even if it doesn't match the defined type.
  • Is Read-Only — Indicates if the field is immutable after initial set.
  • Options — Additional configuration options including default value expression, validation assertion expression, whether field is an array, and if the field can be optional (null/undefined).
  • Namespace — Optional namespace override for the operation.
  • Database — Optional database override for the operation.
  • Connection Pooling — Settings to configure database connection pooling for performance (e.g., max/min connections, timeouts, retries).

Output shape

a single object representing the created field's metadata or confirmation of field creation

The output includes the results of the field creation operation for each input item processed. Errors during creation are handled and reported accordingly.

Examples

Example 1: Create a computed field full_name in the users table that concatenates first_name and last_name

Set Table to 'users', Field Name to 'full_name', Field Mode to 'Computed', Field Type to 'string', and use the computation expression 'string::concat($this.first_name, " ", $this.last_name)'.

Links

Discussion