new KeyValueModel()
Data model for key-value databases.
- Source:
Methods
(static) iterateKeys(filter, options) → {AsyncIterator}
Asynchronously iterate all keys in the database. Similar to `.keys()` but
instead allows for iteration over large data sets without having to load
everything into memory at once.
Callback example:
```js
// Given a model named `Color` with two keys `red` and `blue`
var iterator = Color.iterateKeys();
it.next(function(err, key) {
// key contains `red`
it.next(function(err, key) {
// key contains `blue`
});
});
```
Promise example:
```js
// Given a model named `Color` with two keys `red` and `blue`
var iterator = Color.iterateKeys();
Promise.resolve().then(function() {
return it.next();
})
.then(function(key) {
// key contains `red`
return it.next();
});
.then(function(key) {
// key contains `blue`
});
```
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
filter |
Object | An optional filter object with the following
Properties
|
||||||
options |
Object |
- Source:
Returns:
An Object implementing `next(cb) -> Promise`
function that can be used to iterate all keys.
- Type
- AsyncIterator