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
| Option | Type | Description |
|---|---|---|
client | Database | Existing Bun SQLite database |
dataDir | string | Path to SQLite file (:memory: for in-memory) |
options | object | SQLite options |
Options Object
| Option | Type | Description |
|---|---|---|
readonly | boolean | Open in read-only mode |
create | boolean | Create file if it doesn't exist |
readwrite | boolean | Open with read-write access |
strict | boolean | Enable 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)