API reference / @evolu/common / Evolu/Internal / EvoluSchema

Type Alias: EvoluSchema

type EvoluSchema = ReadonlyRecord<string, ReadonlyRecord<string, Type<any, any, any, any, any>>>;

Defined in: packages/common/src/Evolu/Schema.ts:76

Defines the schema of an Evolu database.

Table schema defines columns that are required for table rows. For not required columns, use nullOr.

Example

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

const TodoCategoryId = id("TodoCategory");
type TodoCategoryId = typeof TodoCategoryId.Type;

const NonEmptyString50 = maxLength(50)(NonEmptyString);
type NonEmptyString50 = typeof NonEmptyString50.Type;

// Database schema.
const Schema = {
  todo: {
    id: TodoId,
    title: NonEmptyString1000,
    isCompleted: nullable(SqliteBoolean),
    categoryId: nullable(TodoCategoryId),
  },
  todoCategory: {
    id: TodoCategoryId,
    name: NonEmptyString50,
    json: nullable(SomeJson),
  },
};

Was this page helpful?