You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/api.md
+4-1
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,8 @@ Various options are accepted:
35
35
36
36
-`options.timeout`: the number of milliseconds to wait when executing queries on a locked database, before throwing a `SQLITE_BUSY` error (default: `5000`).
37
37
38
+
-`options.defaultTransactionBehaviour`: Set the default transaction behavior when calling [Database#transaction()](#transactionfunction---function). Can be set as `null` (SQLite Default), `'deferred'`, `'immediate'` or `'exclusive'` (default: `null`).
39
+
38
40
-`options.verbose`: provide a function that gets called with every SQL string executed by the database connection (default: `null`).
39
41
40
42
-`options.nativeBinding`: if you're using a complicated build system that moves, transforms, or concatenates your JS files, `better-sqlite3` might have trouble locating its native C++ addon (`better_sqlite3.node`). If you get an error that looks like [this](https://github.com/JoshuaWise/better-sqlite3/issues/534#issuecomment-757907190), you can solve it by using this option to provide the file path of `better_sqlite3.node` (relative to the current working directory).
if(readonly&&anonymous&&!buffer)thrownewTypeError('In-memory/temporary databases cannot be readonly');
40
41
if(!Number.isInteger(timeout)||timeout<0)thrownewTypeError('Expected the "timeout" option to be a positive integer');
41
42
if(timeout>0x7fffffff)thrownewRangeError('Option "timeout" cannot be greater than 2147483647');
42
43
if(verbose!=null&&typeofverbose!=='function')thrownewTypeError('Expected the "verbose" option to be a function');
43
44
if(nativeBinding!=null&&typeofnativeBinding!=='string'&&typeofnativeBinding!=='object')thrownewTypeError('Expected the "nativeBinding" option to be a string or addon object');
45
+
if(defaultTransactionBehavior!=null){
46
+
if(typeofdefaultTransactionBehavior!=='string')thrownewTypeError('Expected the "defaultTransactionBehavior" option to be a string, expected "deferred", "immediate", or "exclusive"')
47
+
if(!["deferred","immediate","exclusive"].includes(defaultTransactionBehavior))thrownewError('Invalid value for "defaultTransactionBehavior", expected "deferred", "immediate", or "exclusive"')
48
+
}
44
49
45
50
// Load the native addon
46
51
letaddon;
@@ -66,7 +71,7 @@ function Database(filenameGiven, options) {
0 commit comments