Auto-Increment
SpacetimeDB: Auto-Increment ↗
Auto-increment is column metadata on a primary key. Chain .primaryKey() before
.autoInc() so the declaration satisfies SpacetimeDB’s host rules.
import * as Stdb from "effect-spacetimedb"
const issue = Stdb.table("issue", { public: true, columns: { id: Stdb.u64().primaryKey().autoInc(), title: Stdb.string(), },})Scheduled tables derive their auto-increment schedule id for you:
import * as Stdb from "effect-spacetimedb"
const reminderSchedule = Stdb.scheduledTable("reminder_schedule", { columns: { note: Stdb.string(), },})effect-spacetimedb validates auto-increment at declaration time:
.autoInc() without .primaryKey() throws, and defaults cannot be combined with
primary keys or auto-increment columns.
.autoInc() is narrower than .primaryKey(): only the integer widths carry a
sequence. A string, identity, UUID, timestamp, or sum primary key is a legal key
but rejects .autoInc() — allocate those values in the handler.
Not affiliated with SpacetimeDB (Clockwork Laboratories) or Effect (Effectful Technologies).