kysely-bun-worker
v0.7.0
Published
kysely dialect for bun:sqlite, running in worker
Downloads
3,603
Maintainers
Readme
kysely-bun-worker
kysely dialect for bun:sqlite
, run sql in worker
From v0.7.0
, this dialect requires Bun@^1.1.14
Install
bun install kysely kysely-bun-worker
Usage
import { BunWorkerDialect } from 'kysely-bun-worker'
const dialect = new SqliteWorkerDialect({
url: ':memory:',
})
Custom Worker
in worker.ts
import { createOnMessageCallback } from 'kysely-bun-worker'
onmessage = createOnMessageCallback(
async (db) => {
db.loadExtension(/* ... */)
}
)
Config
export type BunWorkerDialectConfig = {
/**
* db file path
*
* @default ':memory:'
*/
url?: string
onCreateConnection?: (connection: DatabaseConnection) => Promisable<void>
/**
* use bun:sqlite's built-in statment cache
* @see https://bun.sh/docs/api/sqlite#query
*/
cacheStatment?: boolean
/**
* custom worker, default is a worker that use bun:sqlite
*/
worker?: Worker
}