-
Notifications
You must be signed in to change notification settings - Fork 182
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
Document how to promisify with bluebird #293
Comments
Here is the wrapper I use that provides a promisified library. 'use strict';
var P = require('bluebird')
var cradle = require('cradle')
var CouchSchema = require('./CouchSchema')
var config = require('../config')
//make some promises
P.promisifyAll(cradle)
//setup our client
var client = new (cradle.Connection)(
config.couchdb.host,
config.couchdb.port,
config.couchdb.options
)
//make some promises
P.promisifyAll(client)
/**
* Setup the DB access
* @type {object}
*/
client.db = P.promisifyAll(client.database(config.couchdb.database))
/**
* Add schema to helper
* @type {CouchShema}
*/
client.schema = new CouchSchema(config.couchdb.prefix)
/**
* Export client
* @return {object} client
*/
module.exports = client |
Please provide this kind of wrapper as part of Cradle. "It's the current year!" |
honestly callbacks should be removed completely (except for events), bad for readability, bad for error handling (especially when you try to promisify it, because bluebird is a mess when it comes to errors) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This library looks really nice and I was going to use it for a small project, but I can't figure out how to promisify it with bluebird. If you put a little code snippet in the readme showing how it would make the library more usable.
The text was updated successfully, but these errors were encountered: