Skip to main content

Schema<S>

A schema is a collection of tables. It is used to define the structure of a database.

Type Parameters

Type ParameterDefault type
S extends SchemaTypeSchemaType

Constructors

new Schema()

new Schema<S>(tables): Schema<S>

Parameters

ParameterType
tablesS | Table<ColumnsType>[]

Returns

Schema<S>

Properties

PropertyModifierType
propsreadonlyS
rawTablesreadonlyRawTable[]
tablesreadonlyTable<ColumnsType>[]
typesreadonlySchemaTableType<S>

Methods

toJSON()

toJSON(): {
raw_tables: RawTable[];
tables: {
columns: {
name: string;
type: undefined | ColumnType;
}[];
ignore_empty_update: boolean;
include_metadata: boolean;
include_old: any;
include_old_only_when_changed: boolean;
indexes: {
columns: {
ascending: undefined | boolean;
name: string;
type: ColumnType;
}[];
name: string;
}[];
insert_only: boolean;
local_only: boolean;
name: string;
view_name: string;
}[];
}

Returns

{
raw_tables: RawTable[];
tables: {
columns: {
name: string;
type: undefined | ColumnType;
}[];
ignore_empty_update: boolean;
include_metadata: boolean;
include_old: any;
include_old_only_when_changed: boolean;
indexes: {
columns: {
ascending: undefined | boolean;
name: string;
type: ColumnType;
}[];
name: string;
}[];
insert_only: boolean;
local_only: boolean;
name: string;
view_name: string;
}[];
}
NameType
raw_tablesRawTable[]
tables{ columns: { name: string; type: undefined | ColumnType; }[]; ignore_empty_update: boolean; include_metadata: boolean; include_old: any; include_old_only_when_changed: boolean; indexes: { columns: { ascending: undefined | boolean; name: string; type: ColumnType; }[]; name: string; }[]; insert_only: boolean; local_only: boolean; name: string; view_name: string; }[]

validate()

validate(): void

Returns

void


withRawTables()

withRawTables(tables): void

Experimental

Adds raw tables to this schema. Raw tables are identified by their name, but entirely managed by the application developer instead of automatically by PowerSync. Since raw tables are not backed by JSON, running complex queries on them may be more efficient. Further, they allow using client-side table and column constraints. Note that raw tables are only supported when using the new SyncClientImplementation.rust sync client.

Parameters

ParameterTypeDescription
tablesRecord<string, RawTableType>An object of (table name, raw table definition) entries. Note that the raw tables API is still experimental and may change in the future.

Returns

void