API reference@evolu/commonlocal‑first/Schema › EvoluSchema

type EvoluSchema = ReadonlyRecord<string, TableSchema>;

Defined in: packages/common/src/local-first/Schema.ts:81

Defines the schema of an Evolu database.

Column types are Standard Schema v1 compatible — use Evolu Type, Zod, Valibot, ArkType, or any library that implements Standard Schema.

Table schema defines columns that are required for table rows. For optional columns, use a schema whose output type includes null.

Example

// With Evolu Type
const TodoId = id("Todo");
type TodoId = typeof TodoId.Type;

const Schema = {
  todo: {
    id: TodoId,
    title: NonEmptyString100,
    isCompleted: nullOr(SqliteBoolean),
  },
};

// With Zod (or any Standard Schema library)
const Schema = {
  todo: {
    id: TodoId, // Evolu id() for branded IDs
    title: z.string().min(1).max(100),
    isCompleted: z.union([z.literal(0), z.literal(1)]).nullable(),
  },
};