Pyr8 User's Manual
The Database API
Databases are an important part of most many applications
and pyr8 offers a high-performance, reliable, transactional
key/value store as part of its core APIs. Pyr8 uses a
memory-mapped database called LightningDB, which offers b-tree
indexing of arbitrary key/value data. The Pyr8 API wraps this
developers can use to provide very fast local persistence for
Databases are accessed by calling the openDatabase() method
on Directory objects.
The Database Class
Databases in Pyr8 are used to store string-valued key/value
pairs through a Map interface. The maps themselves are pyr8
capabilities, but the individual entries are simply strings or
- cap(): capability<utils>
- Returns a C++-backed capability object for this
- clear(): void
- Clears all values from the Database.
- drop(): void
- Drop the current Map completely.
- delete(key: string):
- Delete key and its value from the Database.
- Returns a new Iterator object that contains the [key,
value] pairs for each element in the Map object in key
- Executes a provided function once per key/value pair in
the Database in key order.
- get(key: string): string
- Returns a specified element from the Database or
undefined if the key is not found.
- has(key: string): bool
- Returns true if the key is in the Database.
- keys(): list<string>
- Returns a list of keys in the database.
- set(key: string, value: string):
- Database Sets the specified key to the given value.
- set(key: string, value: ArrayBuffer): Database
- Sets the specified key to the given value.
- values(): list<ArrayBuffer><>dt>
- Returns a list of ArrayBuffers containing the values in
The above interface is a simplified version of the low-level
LMDB API, which is also available to programmers through the