Quark
#
Modules #
quark/actionquark/appquark/bubblesquark/bufferquark/checkboxquark/cssquark/ctrquark/defsquark/dialogquark/eventquark/fontquark/fsquark/hashquark/httpquark/indexquark/jsonbquark/keyboardquark/lmdbquark/mediaquark/navquark/netquark/osquark/pathquark/pkgquark/screenquark/statequark/stepperquark/storagequark/testquark/typesquark/uriquark/utilquark/viewquark/windowquark/wsquark/_bufferquark/_commonquark/_decoratorsquark/_eventquark/_extquark/_md5quark/_sha1quark/_sha256quark/_utilquark/_watching
Quark v1.4.0 Documentation
Contents
quark/lmdb #
DBI #
Database table Identifier
type DBI = Uint8Array
Interface: Stat #
Stat #
LMDB database statistics.
Class: LMDB #
LMDB #
High-level LMDB wrapper with automatic JSONB encoding. All values stored by this class are encoded using: jsonb.binaryify(value) All values retrieved are decoded using: jsonb.parse(buffer) This provides type-safe persistent storage:
- numbers keep type
- booleans keep type
- arrays/objects keep structure
- Date, Buffer, BigInt are preserved Calling setBuf() directly is disabled to avoid bypassing JSONB.
lmdb.constructor(path,max_dbis?,map_size?) #
Create an LMDB storage wrapper. Automatically calls NativeLMDB.Make(), so user code never touches the native factory directly.
constructor(path: string, max_dbis: any, map_size: any, max_dbis?: Uint, map_size?: Uint)
Parameters:
path— Filesystem directory used to store the LMDB environment.max_dbis— Maximum number of named sub-databases (DBI).Default = 64. Each DBI corresponds to one logical “table”.map_size— Initial mmap size in bytes.Default = 10,485,760 bytes (~10 MB). LMDB will grow automatically if needed (OS allowing), but a larger initial size can reduce remap operations.
The constructor does NOT open the environment immediately — actual opening happens lazily on the first dbi/get/set/scan call.
lmdb.opened #
Whether the LMDB environment is already opened.
readonly opened: boolean
lmdb.open() #
Open the LMDB environment.
open(): Int
Returns: 0 on success, non-zero on error.
lmdb.close() #
Close the LMDB environment.
close(): Int
Returns: 0 on success.
lmdb.flush() #
Flush any pending changes to disk.
flush(): Int
Returns: 0 on success.
lmdb.nextId(dbi) #
Internal nextId counter for generating unique keys.
nextId(dbi: DBI): Int
Returns: Next unique integer ID, if < 0 indicates error.
lmdb.dbi(table) #
Open or create a named database table. There will be mutex locking when calling, so it is best to cache the returned DBI.
dbi(table: string): DBI
Parameters:
table— - Logical table name.
Returns: DBI (opaque binary identifier).
lmdb.dbiStat(dbi) #
Get database statistics for a given DBI/table.
dbiStat(dbi: DBI): Stat
lmdb.getBuf(dbi,key) #
Read raw binary value. Suitable for JSONB, images, or binary assets.
getBuf(dbi: DBI, key: string): Uint8Array | null
lmdb.remove(dbi,key) #
Remove a key.
remove(dbi: DBI, key: string): Int
lmdb.has(dbi,key) #
Check if a key exists.
has(dbi: DBI, key: string): boolean
lmdb.fuzzExists(dbi,prefix) #
Check whether any key with the given prefix exists.
fuzzExists(dbi: DBI, prefix: string): boolean
lmdb.removePrefix(dbi) #
Remove all keys under a prefix.
removePrefix(dbi: DBI): Int
lmdb.clear(dbi) #
Clear all keys in this DBI/table.
clear(dbi: DBI): Int
Type parameters: T
@paramdbi: - Table identifier.@paramkey: - Key string.
Type parameters: T
@paramlimit: - Maximum number of entries to return. Default = 0 (no limit).
@paramlimit: - Maximum number of entries to return. Default = 0 (no limit).