memory service schema added

This commit is contained in:
Storme-bit
2026-04-04 05:49:57 -07:00
parent ebbeecfa1a
commit 5d51aa9895
3 changed files with 90 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
const Database = require('better-sqlite3');
const schema = require('./schema');
const {getEnv } = require('@nexusai/shared');
let db; // Declare db variable in a scope accessible to all functions
function getDB() {
if (!db) {
const path = getEnv('SQLITE_PATH', './data/nexusai.db');
db = new Database(path);
db.pragma('journal_mode = WAL');
db.pragma('foreign_keys = ON');
db.exec(schema);
console.log(`Connected to SQLite database at ${path}`);
}
return db;
}
module.exports = {
getDB
};