Schema<S>
A schema is a collection of tables. It is used to define the structure of a database.
Type Parameters
| Type Parameter | Default type |
|---|---|
S extends SchemaType | SchemaType |
Constructors
new Schema()
new Schema<S>(tables): Schema<S>
Parameters
| Parameter | Type |
|---|---|
tables | S | Table<ColumnsType>[] |
Returns
Schema<S>
Properties
| Property | Modifier | Type |
|---|---|---|
props | readonly | S |
rawTables | readonly | RawTable[] |
tables | readonly | Table<ColumnsType>[] |
types | readonly | SchemaTableType<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;
}[];
}
| Name | Type |
|---|---|
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; }[] |
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
| Parameter | Type | Description |
|---|---|---|
tables | Record<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