MicroDBBase
The api of the MicroDBBase class.
The MicroDBBase class is the heart of the micro-db package. It manages reading and writing to files.
constructor()
constructor()
options
Partial<MicroDBOptions>
isInitialized
isInitialized
Returns true when the db is initialized.
Type: readonly boolean
fileName
fileName
Returns the filename of the db-file.
Type: readonly string
dataSerializer
dataSerializer
Returns a reference to the active serializer.
Type: readonly MicroDBSerializer
janitor
janitor
Returns a reference to the active janitor instance (if a janitorCronjob got defined in the options).
Type: readonly MicroDBJanitor | undefined
initialize()
initialize()
Initialize the Database (read in existing data, setup the writeStream, etc.)
Returns: Promise<void>
read()
read()
Get the current dataset of the database.
Returns: Promise<MicroDBData>()
write()
write()
Write a single record into the db file.
id
string
data
any
Returns: Promise<void>
writeBatch()
writeBatch()
Write multiple records into the file at once.
data
MicroDBData
Returns: Promise<void>
deallocate()
deallocate()
Free up memory space by ending the writeStream and removing all stored data from RAM. The Janitor will keep running.
Returns: Promise<void>
close()
close()
Ends the writeStream and kills the janitor (if existing).
Returns: Promise<void>
Last updated