Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use level-manifest instead of hard-coding #1

Open
edef1c opened this issue Jun 15, 2015 · 2 comments
Open

Use level-manifest instead of hard-coding #1

edef1c opened this issue Jun 15, 2015 · 2 comments

Comments

@edef1c
Copy link
Member

edef1c commented Jun 15, 2015

Hardcoding the set of methods makes it impossible to apply this to LevelUp extensions too.
https://github.com/nathan7/level-promise uses level-manifest instead, so it works with any LevelUp extension that adheres to the level-manifest spec.

@ForbesLindesay
Copy link
Member

I've added you as an owner npm. If you want to release new versions, feel free. I'm not actively using this so I've been a bad steward of it so far.

@abacaj
Copy link

abacaj commented Feb 15, 2017

You don't need this anymore.

Just use bluebird promisify save file as db.js:

Promise = require('bluebird');
const levelup = require('level');

function createDb(dbPath) {
	let db = levelup(dbPath);
	return Promise.promisifyAll(db);
}

module.exports = createDb('./mydb');

and put values like so:

const db = require('./db');
db.putAsync('key','value').then(() => {});

or read values like so

const db = require('./db');
db.getAsync('key')
	.then((e) => {
		console.log(e);
	})
	.catch((err) => {
		console.log(err);
	})


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants