Versie 0.3.3
This commit is contained in:
1 parent
1cf6eeed29
commit
6e741a51fe
57 files changed
+1362
-2135
No files matched your search
+11
-1
@@ -1,4 +1,4 @@
|
||||
// Generated, do not edit. sha256:95f28c26a77b79beac5f8c6818bd25243362641c1d8549949427a847e4f810f9
|
||||
// Generated, do not edit. sha256:232164f95c0eb5137f0c20ab218bdb9ffd81d26142889e12d2caf11dfbc181a3
|
||||
import { DatabaseSync } from 'node:sqlite';
|
||||
|
||||
export const BUSY_TIMEOUT_MS = 5000;
|
||||
@@ -30,6 +30,16 @@ export function withOtherDatabase(pad, fn) {
|
||||
}
|
||||
}
|
||||
|
||||
export function peekDatabase(pad, fn) {
|
||||
const peek = new DatabaseSync(pad, { readOnly: true });
|
||||
const all = (sql, params = []) => peek.prepare(sql).all(...bind(params)).map(rij => ({ ...rij }));
|
||||
try {
|
||||
return fn({ all, one: (sql, params = []) => all(sql, params)[0] ?? null });
|
||||
} finally {
|
||||
peek.close();
|
||||
}
|
||||
}
|
||||
|
||||
export function closeDatabase() {
|
||||
if (!db) return;
|
||||
db.close();
|
||||
|
||||
Reference in new issue
Block a user