Database Configuration
When initializing your @direct-sqlite/core Database instance, you can pass a configuration object alongside your native schema map to adjust operational runtime execution behavior.
import { Database } from '@direct-sqlite/core';import SQLite from 'better-sqlite3';
const connection = new SQLite('app.db');
export const db = new Database(connection, { optimize: "WAL", cacheSize: 1000});import { Database } from '@direct-sqlite/core';import { DatabaseSync } from 'node:sqlite';
const connection = new DatabaseSync('app.db');
export const db = new Database(connection, { optimize: "WAL", cacheSize: 1000});import { Database } from '@direct-sqlite/core';import SQLite from 'bun:sqlite';
const connection = new SQLite('app.db');
export const db = new Database(connection, { optimize: "WAL", cacheSize: 1000});Options Matrix
Section titled “Options Matrix”| Option Name | Types | Default | Description |
|---|---|---|---|
optimize | "WAL" | "MEMORY" | "FAST" | undefined | The optimization method for the database. Write Ahead Logging is recommended. |
cacheSize | number | undefined | The amount of queries to cache before they get overwritten. |
Recommended PRAGMA Optimizations
Section titled “Recommended PRAGMA Optimizations”For high-concurrency systems, using Write-Ahead Logging (WAL) mode drastically optimizes parallel read workloads without blocking writer transactions:
optimize: "WAL"