I tried to use bluebird to promisfy couchbase's ottoman ODM library, but it does not work, with this error:
Cannot read property 'then' of undefined
couch.js:
import ottoman from 'ottoman'
import couchbase from 'couchbase';
import Promise from 'bluebird';
Promise.promisifyAll(ottoman);
const cluster = new couchbase.Cluster('couchbase://127.0.0.1');
const bucket = cluster.openBucket('transaction');
ottoman.store = new ottoman.CbStoreAdapter(bucket, ottoman);
export default ottoman;
message.js:
import ottoman from './couch';
const Message = ottoman.model('Message', {
name: 'string'
});
export default Message;
index.js:
import Message from './message';
let message = new Message ({name:'Couch'});
message.save().then((result) => {
console.log(result);
}).catch((err) => {
console.log(err);
})
via Alvin
No comments:
Post a Comment