- BatchExecutor
Class responsible for executing a batch of operations atomically.
- Batch
Class responsible for building a batch of operations.
- MemoryDB
In-memory database extending SortedTree and providing eventing.
- SortedTree
Nested and Sorted structure, extending functionalities from Nested and Storage mixins.
- Node
Represents a Node in a doubly linked list.
- Sorted
Sorted doubly linked list with Map based indexing.
Class responsible for executing a batch of operations atomically.
Kind: global class
- BatchExecutor
- new BatchExecutor(storage, performingUndo)
- instance
- .execute(ops) ⇒
Promise
- .createUndoOps(ops) ⇒
Promise.<Array>
- .getDb([path]) ⇒
Storage
- .buildPromises(ops) ⇒
Array.<Promise>
- .createUndoOp(operation) ⇒
Promise.<Object>
- .execute(ops) ⇒
- static
- .execute(storage, ops) ⇒
Promise
- .execute(storage, ops) ⇒
Creates a BatchExecutor instance.
Param | Type | Default | Description |
---|---|---|---|
storage | Storage |
The storage instance where operations are performed. | |
performingUndo | boolean |
false |
Flag indicating if undo operations should be performed. |
Executes the given operations atomically.
Kind: instance method of BatchExecutor
Returns: Promise
- Resolves when all operations have been executed.
Param | Type | Description |
---|---|---|
ops | Array |
Array of operations to execute. |
Creates undo operations for the given array of operations.
Kind: instance method of BatchExecutor
Returns: Promise.<Array>
- Resolves with an array of undo operations.
Param | Type | Description |
---|---|---|
ops | Array |
The operations for which to create undo operations. |
Gets a database instance based on a given path.
Kind: instance method of BatchExecutor
Returns: Storage
- The database instance.
Param | Type | Description |
---|---|---|
[path] | string |
The sub-path for the database. |
Builds an array of promises for the given operations.
Kind: instance method of BatchExecutor
Returns: Array.<Promise>
- An array of promises representing the operations.
Param | Type | Description |
---|---|---|
ops | Array |
The operations for which to create promises. |
Creates an undo operation for a single operation.
Kind: instance method of BatchExecutor
Returns: Promise.<Object>
- Resolves with the undo operation.
Param | Type | Description |
---|---|---|
operation | Object |
The operation for which to create an undo operation. |
Executes batch operations statically.
Kind: static method of BatchExecutor
Returns: Promise
- Resolves when all operations have been executed.
Param | Type | Description |
---|---|---|
storage | Storage |
The storage instance. |
ops | Array |
Array of operations to execute. |
Class responsible for building a batch of operations.
Kind: global class
- Batch
- new Batch(storage)
- instance
- .put(key, value, [sub]) ⇒
Batch
- .del(key, [sub]) ⇒
Batch
- .build() ⇒
Array
- .exec() ⇒
Promise
- .put(key, value, [sub]) ⇒
- static
- .execute(storage, arr) ⇒
Promise
- .execute(storage, arr) ⇒
Creates a Batch instance.
Param | Type | Description |
---|---|---|
storage | Storage |
The storage instance where operations are performed. |
batch.put(key, value, [sub]) ⇒ Batch
Adds a put operation to the batch.
Kind: instance method of Batch
Returns: Batch
- Returns the current Batch instance.
Param | Type | Description |
---|---|---|
key | any |
The key for the operation. |
value | any |
The value for the operation. |
[sub] | string |
Optional sub-path. |
batch.del(key, [sub]) ⇒ Batch
Adds a delete operation to the batch.
Kind: instance method of Batch
Returns: Batch
- Returns the current Batch instance.
Param | Type | Description |
---|---|---|
key | any |
The key for the operation. |
[sub] | string |
Optional sub-path. |
Builds the batch operations.
Kind: instance method of Batch
Returns: Array
- Array of batch operations.
Executes the batch operations atomically.
Kind: instance method of Batch
Returns: Promise
- Resolves when all operations have been executed.
Executes an array of operations atomically.
Kind: static method of Batch
Returns: Promise
- Resolves when all operations have been executed.
Param | Type | Description |
---|---|---|
storage | Storage |
The storage instance. |
arr | Array |
Array of operations to execute. |
In-memory database extending SortedTree and providing eventing.
Kind: global class
- MemoryDB
- new MemoryDB(opts, ...args)
- instance
- .isReady() ⇒
Promise
- .put(key, value) ⇒
Promise
- .get(key) ⇒
Promise.<any>
- .del(key) ⇒
Promise
- .setOpts(opts) ⇒
MemoryDB
- .collect(type, opts) ⇒
Promise.<Array>
- .batch(ops) ⇒
Promise
|Batch
- .isReady() ⇒
- static
- .parseOptions(opts, defaultOpts) ⇒
object
- .parseOptions(opts, defaultOpts) ⇒
Creates a MemoryDB instance.
Param | Type | Description |
---|---|---|
opts | object |
Options for the MemoryDB. |
...args | any |
Additional arguments. |
Checks if the database is ready.
Kind: instance method of MemoryDB
Returns: Promise
- Resolves when the database is ready.
Puts a key-value pair into the database and emits a 'put' event.
Kind: instance method of MemoryDB
Returns: Promise
- Resolves when the put operation is complete.
Param | Type | Description |
---|---|---|
key | any |
The key to store. |
value | any |
The value to store. |
Retrieves a value associated with a key from the database.
Kind: instance method of MemoryDB
Returns: Promise.<any>
- The associated value.
Param | Type | Description |
---|---|---|
key | any |
The key to retrieve. |
Deletes a key-value pair from the database and emits a 'del' event.
Kind: instance method of MemoryDB
Returns: Promise
- Resolves when the delete operation is complete.
Param | Type | Description |
---|---|---|
key | any |
The key to delete. |
memoryDB.setOpts(opts) ⇒ MemoryDB
Sets additional options for the database.
Kind: instance method of MemoryDB
Returns: MemoryDB
- The updated MemoryDB instance.
Param | Type | Description |
---|---|---|
opts | object |
Additional options. |
Collects key-value pairs based on the provided type and options.
Kind: instance method of MemoryDB
Returns: Promise.<Array>
- An array of collected data.
Param | Type | Description |
---|---|---|
type | string | boolean | object |
The type of data to collect ('key', 'value', or 'read'). |
opts | object |
Options for collecting data. |
memoryDB.batch(ops) ⇒ Promise
| Batch
Creates or executes a batch operation.
Kind: instance method of MemoryDB
Returns: Promise
| Batch
- Returns a Promise if operations are provided, otherwise returns a new Batch instance.
Param | Type | Description |
---|---|---|
ops | Array |
An array of batch operations. |
Parses the given options.
Kind: static method of MemoryDB
Returns: object
- Parsed options.
Param | Type | Description |
---|---|---|
opts | object |
The options to parse. |
defaultOpts | object |
Default options. |
Nested and Sorted structure, extending functionalities from Nested and Storage mixins.
Kind: global class
Creates a SortedTree instance.
Param | Type | Description |
---|---|---|
opts | object |
Options for the SortedTree. |
...args | any |
Additional arguments. |
Encodes the key.
Kind: instance method of SortedTree
Returns: any
- - The encoded key.
Param | Type | Description |
---|---|---|
key | any |
The key to be encoded. |
Encodes the value.
Kind: instance method of SortedTree
Returns: any
- - The encoded value.
Param | Type | Description |
---|---|---|
value | any |
The value to be encoded. |
Decodes the key.
Kind: instance method of SortedTree
Returns: any
- - The decoded key.
Param | Type | Description |
---|---|---|
key | any |
The key to be decoded. |
Decodes the value.
Kind: instance method of SortedTree
Returns: any
- - The decoded value.
Param | Type | Description |
---|---|---|
value | any |
The value to be decoded. |
Inserts or updates a key-value pair.
Kind: instance method of SortedTree
Param | Type | Description |
---|---|---|
key | any |
The key to insert or update. |
value | any |
The value to insert or update. |
Retrieves a value by its key.
Kind: instance method of SortedTree
Returns: any
- - The retrieved value, or null if the key doesn't exist.
Param | Type | Description |
---|---|---|
key | any |
The key for which to retrieve the value. |
Deletes a key-value pair by its key.
Kind: instance method of SortedTree
Param | Type | Description |
---|---|---|
key | any |
The key to delete. |
sortedTree.sub(path, opts) ⇒ SortedTree
Creates a sub SortedTree.
Kind: instance method of SortedTree
Returns: SortedTree
- - The sub SortedTree.
Param | Type | Description |
---|---|---|
path | string | array |
The path for the sub SortedTree. |
opts | object |
Additional options. |
An iterator over the SortedTree.
Kind: instance method of SortedTree
Param | Type | Description |
---|---|---|
opts | object |
Iterator options. |
Lists all key-value pairs.
Kind: instance method of SortedTree
Param | Type | Description |
---|---|---|
opts | object |
Additional options for listing. |
Represents a Node in a doubly linked list.
Creates a new Node instance.
Param | Type | Description |
---|---|---|
key | any |
The key associated with the node. |
value | any |
The value associated with the node. |
Sorted doubly linked list with Map based indexing.
Kind: global class
- Sorted
- new Sorted(opts)
- .put(key, value)
- .get(key) ⇒
any
|null
- .del(key)
- .iterator(opts)
- .createReadStream(opts, mode) ⇒
Readable
- .createKeyStream(opts) ⇒
Readable
- .createValueStream(opts) ⇒
Readable
- .listAll()
Creates a Sorted instance.
Param | Type | Description |
---|---|---|
opts | object |
Options for the Sorted list. |
opts.comparator | function |
The comparator function to sort the keys. |
Inserts or updates a key-value pair in the list.
Kind: instance method of Sorted
Param | Type | Description |
---|---|---|
key | any |
The key to insert or update. |
value | any |
The value associated with the key. |
Retrieves a value from the list based on the key.
Kind: instance method of Sorted
Returns: any
| null
- Returns the value if the key exists, otherwise returns null.
Param | Type | Description |
---|---|---|
key | any |
The key to search for. |
Deletes a key-value pair from the list based on the key.
Kind: instance method of Sorted
Param | Type | Description |
---|---|---|
key | any |
The key to delete. |
Iterator function for the list based on the given options.
Kind: instance method of Sorted
Param | Type | Description |
---|---|---|
opts | object |
Options for the iterator. |
opts.reverse | boolean |
Whether to reverse the order of iteration. |
Creates a readable stream based on the iterator.
Kind: instance method of Sorted
Returns: Readable
- Returns a readable stream.
Param | Type | Default | Description |
---|---|---|---|
opts | object |
Options for the readable stream. | |
mode | string |
"kv" |
Mode specifying the type of data to stream ('k', 'v', 'kv'). |
Creates a key-only readable stream.
Kind: instance method of Sorted
Returns: Readable
- Returns a readable stream.
Param | Type | Description |
---|---|---|
opts | object |
Options for the readable stream. |
Creates a value-only readable stream.
Kind: instance method of Sorted
Returns: Readable
- Returns a readable stream.
Param | Type | Description |
---|---|---|
opts | object |
Options for the readable stream. |
Logs all key-value pairs in the list.
Kind: instance method of Sorted