I want to use promisify couchbase
In npm , https://www.npmjs.com/search?q=couchbase%20promise , there is no good module , So I am using bluebird
and Promise.promisifyAll(couchbase)
bluebird works well , for instance bucket.getAsync works , But bucket.lookupInAsync
throws TypeError('Second argument needs to be an object if set.')
I tries bucket.lookupIn('key').get('field')..executeAsync();
but executeAsync
is undefined
How can I promisify LookupInBuilder
?
Hi @socketman2016
Bluebird assumes that all function’s it is to promisify has a callback as the last parameter. However, the LookupInBuilder uses a builder pattern, so doesn’t work as expected.
I think you’ll need to create a custom promise for LookupIn.Get, Exists, etc.
1 Like
Can you tell me how exactly? Must I wrap methods??
Why couchnode don’t support promise it self?
I’m not an expert with bluebird, their documentation seems mostly complete or you can try to get help using one of their support options: http://bluebirdjs.com/docs/support.html
We try to expose a consistent API across all language implementations, sometimes that means we use a builder pattern instead of something idiomatic to the language. We try to favour what is normal for a given language, but sometimes it’s not possible / easy to do.
1 Like