"@squeep/api-dingus": "^2",
"@squeep/logger-json-console": "^3",
"argon2": "^0.43.0",
- "better-sqlite3": "^9.4.3",
+ "better-sqlite3": "^11",
"pg-promise": "^11",
"pm2": "^6",
"uuid": "^11"
},
"devDependencies": {
- "@squeep/eslint-config": "^1.0.2",
+ "@squeep/eslint-config": "^1",
"eslint": "^9",
"husky": "^9.1.7",
"mocha": "^11",
"url": "https://opencollective.com/eslint"
}
},
+ "node_modules/@eslint/eslintrc/node_modules/globals": {
+ "version": "14.0.0",
+ "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz",
+ "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==",
+ "dev": true,
+ "engines": {
+ "node": ">=18"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/@eslint/js": {
"version": "9.29.0",
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.29.0.tgz",
"eslint": ">= 9"
}
},
- "node_modules/@squeep/eslint-config/node_modules/eslint-plugin-sonarjs": {
- "version": "1.0.4",
- "resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-1.0.4.tgz",
- "integrity": "sha512-jF0eGCUsq/HzMub4ExAyD8x1oEgjOyB9XVytYGyWgSFvdiJQJp6IuP7RmtauCf06o6N/kZErh+zW4b10y1WZ+Q==",
- "dev": true,
- "engines": {
- "node": ">=16"
- },
- "peerDependencies": {
- "eslint": "^8.0.0 || ^9.0.0"
- }
- },
- "node_modules/@squeep/eslint-config/node_modules/globals": {
- "version": "15.15.0",
- "resolved": "https://registry.npmjs.org/globals/-/globals-15.15.0.tgz",
- "integrity": "sha512-7ACyT3wmyp3I61S4fG682L0VA2RGD9otkqGJIwNUMF1SWUombIIk+af1unuDYgMm082aHYwD+mzJvv9Iu8dsgg==",
- "dev": true,
- "engines": {
- "node": ">=18"
- },
- "funding": {
- "url": "https://github.com/sponsors/sindresorhus"
- }
- },
"node_modules/@squeep/log-helper": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@squeep/log-helper/-/log-helper-1.0.1.tgz",
}
},
"node_modules/better-sqlite3": {
- "version": "9.6.0",
- "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-9.6.0.tgz",
- "integrity": "sha512-yR5HATnqeYNVnkaUTf4bOP2dJSnyhP4puJN/QPRyx4YkBEEUxib422n2XzPqDEHjQQqazoYoADdAm5vE15+dAQ==",
+ "version": "11.10.0",
+ "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-11.10.0.tgz",
+ "integrity": "sha512-EwhOpyXiOEL/lKzHz9AW1msWFNzGc/z+LzeB3/jnFJpxu+th2yqvzsSWas1v9jgs9+xiXJcD5A8CJxAG2TaghQ==",
"hasInstallScript": true,
"dependencies": {
"bindings": "^1.5.0",
"balanced-match": "^1.0.0"
}
},
- "node_modules/eslint-plugin-n/node_modules/globals": {
- "version": "15.15.0",
- "resolved": "https://registry.npmjs.org/globals/-/globals-15.15.0.tgz",
- "integrity": "sha512-7ACyT3wmyp3I61S4fG682L0VA2RGD9otkqGJIwNUMF1SWUombIIk+af1unuDYgMm082aHYwD+mzJvv9Iu8dsgg==",
- "dev": true,
- "engines": {
- "node": ">=18"
- },
- "funding": {
- "url": "https://github.com/sponsors/sindresorhus"
- }
- },
"node_modules/eslint-plugin-n/node_modules/minimatch": {
"version": "9.0.5",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
"url": "https://opencollective.com/eslint"
}
},
+ "node_modules/eslint-plugin-sonarjs": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-1.0.4.tgz",
+ "integrity": "sha512-jF0eGCUsq/HzMub4ExAyD8x1oEgjOyB9XVytYGyWgSFvdiJQJp6IuP7RmtauCf06o6N/kZErh+zW4b10y1WZ+Q==",
+ "dev": true,
+ "engines": {
+ "node": ">=16"
+ },
+ "peerDependencies": {
+ "eslint": "^8.0.0 || ^9.0.0"
+ }
+ },
"node_modules/eslint-scope": {
"version": "8.4.0",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz",
}
},
"node_modules/globals": {
- "version": "14.0.0",
- "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz",
- "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==",
+ "version": "15.15.0",
+ "resolved": "https://registry.npmjs.org/globals/-/globals-15.15.0.tgz",
+ "integrity": "sha512-7ACyT3wmyp3I61S4fG682L0VA2RGD9otkqGJIwNUMF1SWUombIIk+af1unuDYgMm082aHYwD+mzJvv9Iu8dsgg==",
"dev": true,
"engines": {
"node": ">=18"
'use strict';
const SQLite = require('better-sqlite3');
-// XXX: const NodeCleanup = require('node-cleanup');
const BaseDatabase = require('../base');
const common = require('../../common');
const DBErrors = require('../errors');
this.changesSinceLastOptimize = BigInt(0);
- /*
- NodeCleanup(() => {
- this._optimize();
- this._closeConnection();
- });
- */
-
this.db.pragma('foreign_keys = on');
this.db.pragma('journal_mode = WAL');
this.db.defaultSafeIntegers(true);
_initStatements() {
this.statement = {
+ _beginImmediate: this.db.prepare('BEGIN IMMEDIATE'),
+ _commit: this.db.prepare('COMMIT'),
+ _rollback: this.db.prepare('ROLLBACK'),
getAuthById: this.db.prepare('SELECT * FROM auth WHERE id = :id'),
getLinkById: this.db.prepare('SELECT * FROM link WHERE id = :id'),
getLinkByUrl: this.db.prepare('SELECT * FROM link WHERE url = :url'),
async transaction(dbCtx, fn, ...rest) {
dbCtx = dbCtx || this.db;
- return await dbCtx.transaction(async (...args) => await fn(...args))(dbCtx, ...rest);
+ try {
+ this.statement._beginImmediate.run();
+ const result = await fn(dbCtx, ...rest);
+ this.statement._commit.run();
+ return result;
+ } finally {
+ if (this.db.inTransaction) {
+ this.statement._rollback.run();
+ }
+ }
}
async getAuthById(dbCtx, id) {