Available the following config options:
{
name,
label,
dbPathAbsolute,
isSqliteStoredInMemory = false,
workerPathAbsolute,
isNotWorkerSpawned = false,
minWorkersCount = 4,
maxWorkersCount = 16,
unacceptableWalFileSize = 100000000,
readonly = false,
fileMustExist = false,
timeout = 5000,
verbose = false
}
-
name
: <string> used to construct the database name: `db-sqlite${name}${label}.db
` -
label
: <string> used to construct the database name: `db-sqlite${name}${label}.db
` -
dbPathAbsolute
: <string> absolute path to specify a folder for storing DB files -
isSqliteStoredInMemory
(by defaultfalse
): <boolean> store DB in memory in-memory database, passing":memory:"
as the first argument into the database options -
workerPathAbsolute
: <string> absolute path to specify a worker file for extending DB async query actions, see base implementation in the ./worker folder and extended implementation in the ./test/extended-worker folder -
isNotWorkerSpawned
(by defaultfalse
): <boolean> not spawn worker threads for async queries -
minWorkersCount
(by default4
): <integer> count spawned workers are equal CPU cores count but not less than this value. If set0
one worker will be spawned anyway -
maxWorkersCount
(by default16
): <integer> count spawned workers are equal CPU cores count but not more than this value -
unacceptableWalFileSize
(by default100000000
): <integer> unacceptable WAL file size in bytes, when the WAL file gets more than passed valuePRAGMA wal_checkpoint(RESTART)
will be executed related to checkpoint starvation -
readonly
(by defaultfalse
): <boolean> open the database connection in readonly mode passing as the second argument into the database options -
fileMustExist
(by defaultfalse
): <boolean> if the database does not exist, an Error will be thrown instead of creating a new file. This option does not affect in-memory or readonly database connections, passing as the second argument into the database options -
timeout
(by default5000
): <integer> the number of milliseconds to wait when executing queries on a locked database, before throwing a SQLITE_BUSY error passing as the second argument into the database options -
verbose
(by defaultfalse
): <boolean> iftrue
theconsole.log
will called with every SQL string executed by the database connection, passingconsole.log
as the second argument into the database options
Sqlite class provides the following methods:
-
.asyncQuery(args)
: provides an async way to delegate a query into DB using implemented worker actions or extended worker actions. For that uses Node.js worker threadsParameters:
args
: <Object>action
(required): <string> action that needs to pick to process logicsql
: <string | Array[string]> SQL that needs to execute by the DB driver via workerparams
: <any> parameters that pass into worker action
Returns:
- <Promise> contains returning action result
-
.initializeWalCheckpointRestart(ms)
: checks WAL file size in bytes which setting inunacceptableWalFileSize
config option, by set interval, when the WAL file gets more than passed valuePRAGMA wal_checkpoint(RESTART)
will be executed related to checkpoint starvationParameters:
ms
(by default 10000): <integer> interval in milliseconds with which the WAL file size will be checked