A simple driver used to connect to any bucket in a couchbase cluster
#!bash
npm install --save couchbase-driver-cornerjob
#!javascript
const CouchbaseDriver = require('couchbase-driver-cornerjob');
const host = '12.345.678.910';
const driver = new CouchbaseDriver(host);
driver
.getBucketConnection('default')
.then(bucket => {
return new Promise((resolve, reject) => {
bucket.get('test', (err, result) => {
if (err) {
return reject(err);
}
resolve(result);
});
});
})
.then(() => {
driver.closeAllBucketConnections();
})
.catch(() => {
driver.closeAllBucketConnections();
});
getBucketConnection() returns a couchbase Bucket class from npm couchbase. To learn more about how to perform bucket operations see the couchbase Node.js SDK