Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

A proper, Class-based, Promisified, Node 8 Native wrapper around level.

License

Notifications You must be signed in to change notification settings

eslachance/native-level-promise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Native Level Promise

A proper, Class-based, Promisified, Node 8 Native wrapper around level.

Installation

npm i native-level-promise

Usage

Most native Level features should work the same in promisified versions. Here are a few examples:

const Level = require('native-level-promise');

db = new Level('./data/mydb');

db.put("test", "thing").then(() => console.log("Value inserted"));

db.del(key).then(() => console.log("Value deleted"));

Note that streams remain the same:

const stream = db.keyStream();
stream.on('data', (key) => {
  this.db.get(key, (err, value) => {
    if (err) console.log(err);
    // do something with value.
  });
});
stream.on('end', () => {
  console.log("Key Stream has ended");
});

And finally

db.close().then(() => {
  console.log("DB has been closed!");
});

I feel I don't need to say this all works with async/await but I'll say it anyway because... because.

About

A proper, Class-based, Promisified, Node 8 Native wrapper around level.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published