level-ordered
A wrapper for level
that keeps inserted items ordered.
All items should be in JSON form.
Usage
// create/access databaseconst testDB = await Database; // insert itemsawait testDB; // get all itemsconst allItems = await testDB;allItems; // ['one', 'two', 'three'] // get last itemawait testDB; // { val: 'three' } // delete item: { val: 'two' }const filterFunc = val === 'two';await testDB;await testDB; // []
API
getAll([filterFunc])
Returns a promise for all items (+ keys as _id
fields), filtered by a function if provided, in an array form.
getKey(key)
Returns a promise for the item matching the key provided.
getLastItem()
Returns a promise for the last inserted item.
insert(...newItems)
Asynchronously inserts items provided into the database.
update(key, updateObj)
Asynchronously updates an item in the database with the object provided.
deleteKey(key)
Asynchronously deletes an item according to key.
deleteBy([filterFunc])
Asynchronously deletes items, filtered by a function if provided.