Litestone guide / Reference
createClient options
createClient takes one options object. It needs a schema from one of path, schema or parsed; everything else is optional.
model Note {
id Int
body String
}
const db = await createClient({ path: './schema.lite', db: ':memory:', now: () => new Date('2026-01-01T00:00:00Z') })
await db.note.create({ data: { body: 'hello' } })
if (await db.note.count() !== 1) throw new Error('expected one note')
The options
path,schemaandparsedare the schema as a file path, as text, or as a pre-parsed resultdbis the file for the main database, and overrides a declareddatabase maindatabasesis':memory:'for every database, or{ name: { path } }for one eachresolveFromanchors a relativedatabase { path }to the cwd, the schema file, or a directoryaccesssets each database to'readwrite','readonly'orfalse, andreadOnlyis the shorthand for allplaceModelsputs a named model in a named database for this client onlybusyTimeoutis the milliseconds to wait for another process's write lockencryptionKeyis the 64-character hex key for@encryptedand@secret, andpreviousEncryptionKeysare keys it may still read withpluginstakesGatePlugin,FileStorageand custom pluginsclaimsdeclares the principal's per-request claim names beyond the@@authcolumnsuntrustedbuilds schema text the app did not write, refusing anything that could name a filecomputedsupplies the functions behind computed fields, or the path of a file exporting themfiltersadds a permanentwhereto every read on a modelscopesregisters named query fragments per modelhooksrunsbeforeandafterfunctions around reads and writesonEventlistens forcreate,update,removeandchangeafter commit, andannouncesets what a bulk write announcesonQuerysees every verb the client runs, andonLogandlogContextenrich audit-trail entriesnowis the clock the client reads and writespluralizepluralizes snake_case table namespolicyDebuglogs policy decisionsallowChildFkOverridelets an explicit child value win over the parent's in a nested create
In depth: Getting started § createClient options, § Where the database file comes from, § A schema that is data