Class: Database

Database(databasePath, bufferManagerSize, enableCompression, readOnly, maxDBSize, autoCheckpoint, checkpointThreshold, throwOnWalReplayFailure, enableChecksums)

new Database(databasePath, bufferManagerSize, enableCompression, readOnly, maxDBSize, autoCheckpoint, checkpointThreshold, throwOnWalReplayFailure, enableChecksums)

Initialize a new Database object. Note that the initialization is done lazily, so the database file is not opened until the first query is executed. To initialize the database immediately, call the `init()` function on the returned object.
Parameters:
Name Type Default Description
databasePath String path to the database file. If the path is not specified, or empty, or equal to `:memory:`, the database will be created in memory.
bufferManagerSize Number 0 size of the buffer manager in bytes.
enableCompression Boolean true whether to enable compression.
readOnly Boolean false if true, database will be opened in read-only mode.
maxDBSize Number 0 maximum size of the database file in bytes. Note that this is introduced temporarily for now to get around with the default 8TB mmap address space limit some environment.
autoCheckpoint Boolean true If true, the database will automatically checkpoint when the size of the WAL file exceeds the checkpoint threshold.
checkpointThreshold Number The threshold of the WAL file size in bytes. When the size of the WAL file exceeds this threshold, the database will checkpoint if autoCheckpoint is true.
throwOnWalReplayFailure Boolean true If true, any WAL replaying failure when loading the database will throw an error. Otherwise, Lbug will silently ignore the failure and replay up to where the error occured.
enableChecksums Boolean true If true, the database will use checksums to detect corruption in the WAL file.
Source:

Methods

(async) _getDatabase() → {LbugNative.NodeDatabase}

Internal function to get the underlying native database object.
Source:
Throws:
if the database is closed.
Type
Error
Returns:
the underlying native database.
Type
LbugNative.NodeDatabase

_getDatabaseSync() → {LbugNative.NodeDatabase}

Internal function to get the underlying native database object synchronously.
Source:
Throws:
if the database is closed.
Type
Error
Returns:
the underlying native database.
Type
LbugNative.NodeDatabase

(async) close()

Close the database.
Source:

closeSync()

Close the database synchronously.
Source:
Throws:
if there is an ongoing asynchronous initialization.
Type
Error

(async) init()

Initialize the database. Calling this function is optional, as the database is initialized automatically when the first query is executed.
Source:

initSync()

Initialize the database synchronously. Calling this function is optional, as the database is initialized automatically when the first query is executed. This function may block the main thread, so use it with caution.
Source:

(static) getStorageVersion() → {Number}

Get the storage version of the library.
Source:
Returns:
the storage version of the library.
Type
Number

(static) getVersion() → {String}

Get the version of the library.
Source:
Returns:
the version of the library.
Type
String