Lix = {
call
: (name
:string
,payload?
:unknown
,opts?
: {signal?
:AbortSignal
; }) =>Promise
<unknown
>;close
: () =>Promise
<void
>;db
:Kysely
<LixDatabaseSchema
>;engine?
:LixEngine
;hooks
:LixHooks
;observe
:ReturnType
<typeofcreateObserve
>;plugin
: {getAll
: () =>Promise
<LixPlugin
[]>; };toBlob
: () =>Promise
<Blob
>; }
call: (
name
:string
,payload?
:unknown
,opts?
: {signal?
:AbortSignal
; }) =>Promise
<unknown
>
Calls a named engine function and returns its result.
Preferred entrypoint for invoking engine functions.
Parameter | Type |
---|---|
name | string |
payload? | unknown |
opts? | { signal? : AbortSignal ; } |
opts.signal? | AbortSignal |
Promise
<unknown
>
close: () =>
Promise
<void
>
Closes the lix instance and its storage.
Promise
<void
>
db:
Kysely
<LixDatabaseSchema
>
optional
engine:LixEngine
In‑process engine context bound to the live database.
When Lix runs in‑process (same thread as the database),
engine
is available and tests can directly call helpers
that accept { engine }
.
When Lix runs out‑of‑process (for example inside a Worker), the engine
is not accessible from the main thread and will be undefined
. In those
environments, use lix.call
to invoke engine functions across the
boundary.
Guidance:
lix.db
for normal queries and lix.call
for engine
operations. Reserve lix.engine
for unit tests or internal SDK code
that explicitly requires in‑process access alongside the database.lix.engine
in application/business logic, since it
may be undefined
in worker/remote environments.Unit test in the same process
Worker/remote environment – prefer router calls
hooks:
LixHooks
Hooks for listening to database lifecycle events.
Allows registering callbacks that fire at specific points in Lix's execution, such as when state changes are committed.
observe:
ReturnType
<typeofcreateObserve
>
plugin: {
getAll
: () =>Promise
<LixPlugin
[]>; }
getAll: () =>
Promise
<LixPlugin
[]>
Promise
<LixPlugin
[]>
toBlob: () =>
Promise
<Blob
>
Serialises the Lix into a Blob.
Use this helper to persist the current state to disk or send it to a server. The blob contains the raw SQLite file representing the Lix project.
Promise
<Blob
>