interface
sqlite.DatabaseOptions
interface DatabaseOptions
Options for Database
- create?: boolean
Allow creating a new database
Equivalent to constants.SQLITE_OPEN_CREATE
When
false, opening a file that does not exist throws an error with the codeSQLITE_CANTOPEN. - readonly?: boolean
Open the database as read-only (no write operations, no create).
Equivalent to constants.SQLITE_OPEN_READONLY
Together with
create: trueorreadwrite: true, the constructor throws aTypeError. - readwrite?: boolean
Open the database as read-write
Equivalent to constants.SQLITE_OPEN_READWRITE
readwrite: truewithoutcreate: truedoes not create the file.readwrite: falseis the same asreadonly: true. - safeIntegers?: boolean
When
true, integers are returned asbigint.When
false, integers are returned asnumber, and integers beyond 53 bits are rounded to the nearestnumber.When
true, abigintparameter that does not fit in a signed 64-bit integer throws aRangeError. Whenfalse, it keeps its low 64 bits:2n ** 64n - 1nis stored as-1. - strict?: boolean
When set to
true, a query with a missing bound parameter throws an error. When set tofalseorundefined, the parameter isNULL.In both modes, the key of a named parameter can include the
$,:, or@prefix or leave it out. If an object has both keys, the key without the prefix wins in strict mode, and the key with the prefix otherwise.const db = new Database(":memory:", { strict: true }); db.run("INSERT INTO foo (name) VALUES ($name)", { name: "foo" }); db.run("INSERT INTO foo (name) VALUES ($name)", { nmae: "foo" }); // throws