Function: createChangeSet()

createChangeSet(args: { elements?: Omit<NewState<{ change_id: string; change_set_id: string; entity_id: string; file_id: string; schema_key: string; }>, "change_set_id">[]; id?: string; labels?: Pick<{ id: LixGenerated<string>; name: string; }, "id">[]; lix: Pick<Lix, "db" | "sqlite" | "hooks">; lixcol_version_id?: string; }): Promise<{ id: LixGenerated<string>; metadata?: null | Record<string, any>; } & { lixcol_version_id: string; }>

Creates a change set and optionally attaches elements and labels.

Change sets are the building blocks of versions and checkpoints. This function inserts all provided relations in a single transaction and returns the newly created record.

Example

const cs = await createChangeSet({ lix, elements: [{ change_id, entity_id }] })

Parameters

ParameterTypeDescription
args{ elements?: Omit<NewState<{ change_id: string; change_set_id: string; entity_id: string; file_id: string; schema_key: string; }>, "change_set_id">[]; id?: string; labels?: Pick<{ id: LixGenerated<string>; name: string; }, "id">[]; lix: Pick<Lix, "db" | "sqlite" | "hooks">; lixcol_version_id?: string; }-
args.elements?Omit<NewState<{ change_id: string; change_set_id: string; entity_id: string; file_id: string; schema_key: string; }>, "change_set_id">[]-
args.id?string-
args.labels?Pick<{ id: LixGenerated<string>; name: string; }, "id">[]-
args.lixPick<Lix, "db" | "sqlite" | "hooks">-
args.lixcol_version_id?stringVersion ID where the change set should be stored. Defaults to active version

Returns

Promise<{ id: LixGenerated<string>; metadata?: null | Record<string, any>; } & { lixcol_version_id: string; }>