MicroDBDriver
Generic Type <T>
: Type of the data stored in the db
static forDatabase()
static forDatabase()
Generic type <T>
: Type of the data stored in the db
Create a MicroDBDriver instance for a (running) MicroDBBase
instance.
db
MicroDBBase
Returns: Promise<MicroDBDriver<T>>
constructor()
constructor()
options
Partial<MicroDBOptions>
dbRef
dbRef
Returns a reference to the underlying MicroDBBase
.
Type: readonly MicroDBBase
janitor
janitor
Returns a reference to the active janitor instance (if a janitorCronjob got defined in the options).
Type: readonly MicroDBJanitor | undefined
isInitialized()
isInitialized()
Returns the initialization state of the underlying MicroDBBase
.
Type: readonly boolean
initialize()
initialize()
Initialize the underlining MicroDBBase
instance.
Returns: Promise<void>
close()
close()
Closes the underlining MicroDBBase
instance.
Returns: Promise<void>
create()
create()
Create a new database record.
object
T
Returns: Promise<string>
(internal id of the new record)
select()
select()
Select a record by internal id (returned by create
method).
id
string
Returns: Promise<MicroDBEntry<T> | undefined>
selectWhere()
selectWhere()
Select the first record satisfying the predicate.
pred
WherePredicate<T>
Remember: Where-Predicates must be synchronous
Returns: Promise<MicroDBEntry<T> | undefined>
selectAllWhere()
selectAllWhere()
Select all records satisfying the predicate.
pred
WherePredicate<T>
Returns: Promise<MicroDBEntry<T>[]>
selectAll()
selectAll()
Select all records.
Returns: MicroDBEntry<T>[]
update()
update()
Update a record by internal id (returned by create
method).
id
string
object
Partial<T>
Returns: Promise<boolean>
(if record could be updated)
updateWhere()
updateWhere()
Update the first record satisfying the predicate.
pred
WherePredicate<T>
object
Partial<T>
Returns: Promise<boolean>
(if record could be updated)
updateAllWhere()
updateAllWhere()
Update all records satisfying the predicate.
pred
WherePredicate<T>
object
Partial<T>
Returns: Promise<number>
(count of updated records)
mutate()
mutate()
Mutate a record by internal id (returned by create
] method).
id
string
mutation
Mutation<T>
Returns: Promise<boolean>
(if record could be mutated)
mutateWhere()
mutateWhere()
Mutates the first record satisfying the predicate.
pred
WherePredicate<T>
mutation
Mutation<T>
Returns: Promise<boolean>
(if record could be mutated)
mutateAllWhere()
mutateAllWhere()
Mutate all records satisfying the predicate.
pred
WherePredicate<T>
mutation
Mutation<T>
Returns: Promise<number>
(count of mutated records)
mutateAll()
mutateAll()
Mutate all records.
mutation
Mutation<T>
Returns: Promise<number>
(count of mutated records)
delete()
delete()
Delete a record by internal id (returned by create
] method).
id
string
Returns: Promise<boolean>
(if a record could be deleted)
deleteWhere()
deleteWhere()
Delete the first record satisfying the predicate.
pred
WherePredicate<T>
Returns: Promise<oolean>
(if a record could be deleted)
deleteAllWhere()
deleteAllWhere()
Delete all records satisfying the predicate.
pred
WherePredicate<T>
Returns: Promise<number>
(count of deleted records)
flush()
flush()
Delete all data from the database.
Last updated