createQuerySync(
args: {engine:Pick<LixEngine,"executeSync">; }):QuerySyncFunction
Create a synchronous query builder factory bound to an engine.
Returns a querySync(table) function that mirrors Kysely's
selectFrom(table) builder, but with synchronous execution via
.execute(), .executeTakeFirst(), and .executeTakeFirstOrThrow().
When to use
querySync into detectChanges() so
plugins can read current state synchronously while computing changes.querySync from an in‑process Lix (e.g.
InMemoryEnvironment) using createQuerySync({ engine: lix.engine! })
and call your plugin's detectChanges({ querySync, ... }) directly.Engine availability
lix.engine is available and can be passed here.lix.engine is undefined on the host
thread. In those cases, use integration tests that drive the file
handlers or a test environment that exposes the engine.JSON behavior
snapshot_content is parsed to objects to match normal Kysely queries.
Other JSON columns are returned as raw JSON strings; parse if needed.// Unit testing a plugin's detectChanges directly
import { openLix, createQuerySync } from '@lix-js/sdk'
import { detectChanges } from '../src/detect-changes.js'
const lix = await openLix({})
const querySync = createQuerySync({ engine: lix.engine! })
const after = {
id: 'file1',
path: '/doc.md',
data: new TextEncoder().encode('# Hello'),
metadata: {}
}
const changes = detectChanges({ querySync, after })
expect(Array.isArray(changes)).toBe(true)| Parameter | Type |
|---|---|
args | { engine: Pick<LixEngine, "executeSync">; } |
args.engine | Pick<LixEngine, "executeSync"> |
QuerySyncFunction