Skip to content

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
});
Option NameTypesDefaultDescription
optimize"WAL" | "MEMORY" | "FAST"undefinedThe optimization method for the database. Write Ahead Logging is recommended.
cacheSizenumberundefinedThe amount of queries to cache before they get overwritten.

For high-concurrency systems, using Write-Ahead Logging (WAL) mode drastically optimizes parallel read workloads without blocking writer transactions:

optimize: "WAL"