mirror of
https://github.com/screentinker/screentinker.git
synced 2026-08-16 23:33:10 -06:00
Update database.js
This commit is contained in:
parent
6cf86533e4
commit
90e48581e2
|
|
@ -1,4 +1,4 @@
|
||||||
const Database = require('libsql');
|
const Database = require('better-sqlite3');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const config = require('../config');
|
const config = require('../config');
|
||||||
|
|
@ -7,15 +7,7 @@ const { chunkedDelete, yieldTick, currentBand } = require('../lib/chunked-prune'
|
||||||
const dbDir = path.dirname(config.dbPath);
|
const dbDir = path.dirname(config.dbPath);
|
||||||
if (!fs.existsSync(dbDir)) fs.mkdirSync(dbDir, { recursive: true });
|
if (!fs.existsSync(dbDir)) fs.mkdirSync(dbDir, { recursive: true });
|
||||||
|
|
||||||
const dbOptions = {};
|
const db = new Database(config.dbPath);
|
||||||
if (config.bunnyDbUrl && config.bunnyDbAuthToken) {
|
|
||||||
dbOptions.syncUrl = config.bunnyDbUrl;
|
|
||||||
dbOptions.authToken = config.bunnyDbAuthToken;
|
|
||||||
}
|
|
||||||
const db = new Database(config.dbPath, dbOptions);
|
|
||||||
if (dbOptions.syncUrl) {
|
|
||||||
db.sync(); // Initial sync
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enable WAL mode and foreign keys
|
// Enable WAL mode and foreign keys
|
||||||
db.pragma('journal_mode = WAL');
|
db.pragma('journal_mode = WAL');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue