Socket
Book a DemoInstallSign in
Socket

kysely-bun-worker

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kysely-bun-worker

kysely dialect for bun:sqlite, running in worker

Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
1.5K
-8.29%
Maintainers
1
Weekly downloads
 
Created
Source

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 BunWorkerDialect({
  url: ':memory:',
})

Custom Worker

in worker.ts

import { createOnMessageCallback, defaultCreateDatabaseFn } from 'kysely-bun-worker'

createOnMessageCallback(
  async (...args) => {
    const db = defaultCreateDatabaseFn(...args)
    db.loadExtension(/* ... */)
    return db
  }
)

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
}

Keywords

kysely

FAQs

Package last updated on 29 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts