Private
registryPrivate
storageGet the database of the name.
For detailed document, see DBManager
.
Private
get_Conveniently transform data in the given entry in given path. Equivalent to a chain of calls.
See with_path
for more details or writes are needed.
Register a database.
Note that the structure of the database can't be changed once it's registered.
Reregistering is a no-op.
name of the database
initializer of the database, can also be an array if the explicit initializer is too annoying...
Conveniently perform a transaction with the given entry in given path.
If no writes are needed, use peek_path
.
Equivalent to a chain of calls like:
// convenient call
await mgr.with_path<T>(['main', 'sub', ..., 'final sub', 'key'],
async (val) => { 'do sth' });
// equivalent to:
await using subdb = await mgr.db('main').sub('sub')....sub<T>('final sub');
const val = subdb.data['key'];
// do sth
You may return a new value in the transaction to set the entry to the given value.
Generated using TypeDoc
Manager and entry to the databases.
Note: if you want to write to a database, don't forget to
using
it, or data written to the database would lose!You should NOT construct any of its instances, except for unit tests: there's a app-local singleton
app.db
.Usage:
Accessing the same entry concurrently may result in losing data, or conflict between two transactions; here, we choose to copy the entry lazily per database, which is not right, but lock-free, and wouldn't cause any transactions to fail.