VibORM

Bun SQLite

SQLite driver using Bun's built-in SQLite

Requirements

  • Bun runtime

Configuration

import { createClient } from "viborm/drivers/bun-sqlite";

const client = createClient({
  dataDir: "./database.sqlite",
  schema,
});

Options

OptionTypeDescription
clientDatabaseExisting Bun SQLite database
dataDirstringPath to SQLite file (:memory: for in-memory)
optionsobjectSQLite options

Options Object

OptionTypeDescription
readonlybooleanOpen in read-only mode
createbooleanCreate file if it doesn't exist
readwritebooleanOpen with read-write access
strictbooleanEnable strict mode

In-Memory Database

import { createClient } from "viborm/drivers/bun-sqlite";

// Default is in-memory
const client = createClient({
  schema,
});

Read-Only Mode

import { createClient } from "viborm/drivers/bun-sqlite";

const client = createClient({
  dataDir: "./database.sqlite",
  options: { readonly: true },
  schema,
});

Transactions

Bun SQLite supports full transactions with savepoints for nested transactions.

await client.$transaction(async (tx) => {
  await tx.user.create({ data: { name: "Alice" } });
  await tx.post.create({ data: { title: "Hello", authorId: "..." } });
});

Limitations

  • Only available in Bun runtime
  • JSON columns return as strings (VibORM auto-parses JSON relations via tryParseJsonString())
  • Boolean values stored as integers (0/1)
  • Synchronous API internally (async wrapper)

On this page