MCPcopy Create free account
hub / github.com/WiseLibs/better-sqlite3 / getController

Function getController

lib/methods/transaction.js:31–49  ·  view source on GitHub ↗
(db, self)

Source from the content-addressed store, hash-verified

29
30// Return the database's cached transaction controller, or create a new one
31const getController = (db, self) => {
32 let controller = controllers.get(db);
33 if (!controller) {
34 const shared = {
35 commit: db.prepare('COMMIT', self, false, false),
36 rollback: db.prepare('ROLLBACK', self, false, false),
37 savepoint: db.prepare('SAVEPOINT `\t_bs3.\t`', self, false, false),
38 release: db.prepare('RELEASE `\t_bs3.\t`', self, false, false),
39 rollbackTo: db.prepare('ROLLBACK TO `\t_bs3.\t`', self, false, false),
40 };
41 controllers.set(db, controller = {
42 default: Object.assign({ begin: db.prepare('BEGIN', self, false, false) }, shared),
43 deferred: Object.assign({ begin: db.prepare('BEGIN DEFERRED', self, false, false) }, shared),
44 immediate: Object.assign({ begin: db.prepare('BEGIN IMMEDIATE', self, false, false) }, shared),
45 exclusive: Object.assign({ begin: db.prepare('BEGIN EXCLUSIVE', self, false, false) }, shared),
46 });
47 }
48 return controller;
49};
50
51// Return a new transaction function by wrapping the given function
52const wrapTransaction = (apply, fn, db, { begin, commit, rollback, savepoint, release, rollbackTo }) => function sqliteTransaction() {

Callers 1

transaction.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected