keyv-extensions v1.3.7
Keyv-Extensions
Adds functionality and sub content to keyv
Introduction
The idea for this is to have proxy arrays and keyv stores that will allow you to save array or another keyv database inside a keyv database
Examples
Proxy Array
Creating a array linked to a database and adding test value
const keyvExt = require('keyv-extensions');
const arr = keyvExt.keyvArray(keyv, 'arr');
arr[0] = 'test';
Sub Keyv
Creating a sub keyv and setting values
const keyvExt = require('keyv-extensions');
const sub = new Keyv({store: new keyvExt(keyv, 'sub')});
sub.set('test', 'testvalue');
Documentation
Classes
Functions
KeyvSub
A Keyv store, so you can put a keyv db inside another keyv db
Kind: global class
- KeyvSub
- new KeyvSub(database, key)
- .get(key) ⇒ Promise.<any>
- .set(key, value) ⇒ Promise.<true>
- .delete(key) ⇒ Promise.<boolean>
- .clear() ⇒ Promise.<true>
new KeyvSub(database, key)
Param | Type | Description |
---|---|---|
database | Keyv | The database to put the key in |
key | string | Key name |
Example
var sub = new Keyv({store: new KeyvSub(db, 'data')})
keyvSub.get(key) ⇒ Promise.<any>
Gets a value
Kind: instance method of KeyvSub
Returns: Promise.<any> - The value
Param | Type |
---|---|
key | string |
keyvSub.set(key, value) ⇒ Promise.<true>
Sets a key to some value
Kind: instance method of KeyvSub
Returns: Promise.<true> - True if it was succesfull
Param | Type |
---|---|
key | string |
value | any |
keyvSub.delete(key) ⇒ Promise.<boolean>
Deletets a value
Kind: instance method of KeyvSub
Returns: Promise.<boolean> - True if it exists and false if not
Param | Type |
---|---|
key | string |
keyvSub.clear() ⇒ Promise.<true>
Clears the database
Kind: instance method of KeyvSub
Returns: Promise.<true> - True if it was succesfull
keyvArray(database, key, arr) ⇒ Promise.<Array>
Creates a array inside a keyv database
Kind: global function
Returns: Promise.<Array> - Promise with the array
Param | Type | Description |
---|---|---|
database | Keyv | The database to put the array in |
key | string | The key the array will be stored in |
arr | Array | The array to create on |