tables module manages the schema of your custom tables — creating and dropping tables, and adding and dropping columns. For reading and writing rows, see Tables — Rows. For the feature overview, see Custom Tables.
Table management is service-key only, so it lives in the server-side
@sublay/node SDK only — the browser @sublay/js SDK
and the React useTable hook are row-only. The same operations are also
available in the dashboard data editor.custom_ prefix for you.
createTable
Creates a custom table with the given columns and managed-column flags.The logical table name (max 56 characters — 63 minus the
custom_ prefix).
Sublay stores it as custom_<tableName>.The developer columns to create. Each is
{ columnName, dataType, nullable, defaultValue? }.
dataType is one of text, integer, float, decimal, boolean, date,
timestamp, uuid, json. A column may not be named id, createdAt,
updatedAt, or deletedAt (reserved managed columns).Emit
createdAt / updatedAt. Defaults to true.Emit
deletedAt and enable soft delete. Requires timestamps. Defaults to
false.Promise<{ table: string }> — the physical (custom_*) table name.
Errors are returned with a
database/* code: database/reserved-column (a
column shadows a managed name), database/name-too-long (over 56 chars),
database/table-limit-reached (100 tables), database/column-limit-reached
(100 columns).addColumn
Adds a column to an existing custom table.The logical table name.
The new column’s name (may not be a reserved managed name).
One of
text, integer, float, decimal, boolean, date, timestamp,
uuid, json.Whether the column accepts
null.Optional default literal, validated against
dataType.Promise<{ added: string }>
dropColumn
Drops a column from a custom table. Managed columns (id, createdAt, updatedAt, deletedAt) cannot be dropped.
The logical table name.
The column to drop.
Promise<{ dropped: string }>
dropTable
Drops a custom table and all of its rows. This is irreversible.The logical table name.
Promise<{ dropped: string }>
