ctx.database (PluginDatabaseAccessor) opens (or creates) an SQLite database file scoped to your plugin’s data directory at {userData}/plugins-data/{pluginId}/. It returns a better-sqlite3 Database instance.
ctx.config is lighter.Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Per-plugin SQLite storage from a background module.
ctx.database (PluginDatabaseAccessor) opens (or creates) an SQLite database file scoped to your plugin’s data directory at {userData}/plugins-data/{pluginId}/. It returns a better-sqlite3 Database instance.
const db = ctx.database.open("landing-reports.db");
db.exec(`
CREATE TABLE IF NOT EXISTS reports (
id INTEGER PRIMARY KEY AUTOINCREMENT,
flight_id TEXT NOT NULL,
landing_rate REAL,
created_at TEXT DEFAULT (datetime('now'))
)
`);
const insert = db.prepare(
"INSERT INTO reports (flight_id, landing_rate) VALUES (?, ?)",
);
insert.run("VA123", -180.5);
const rows = db.prepare("SELECT * FROM reports").all();
ctx.logger.info("DB", `Found ${rows.length} landing reports`);
ctx.config is lighter.Was this page helpful?