Function: switchVersion()

switchVersion(args: { lix: Lix; to: Pick<Version, "id">; }): Promise<void>

Switches the current Version to the given Version.

The Version must already exist before calling this function.

Examples

await switchVersion({ lix, to: otherVersion });

Switching to a newly created version.

await lix.db.transaction().execute(async (trx) => {
   const newVersion = await createVersion({ lix: { db: trx }, commit: currentVersion });
   await switchVersion({ lix: { db: trx }, to: newVersion });
});

Parameters

ParameterType
args{ lix: Lix; to: Pick<Version, "id">; }
args.lixLix
args.toPick<Version, "id">

Returns

Promise<void>