couchbase-promise
A promise-based asynchronous library for Couchbase and node.js.
The Official Couchbase Node.js Client Library provides only callback functions to handle the result of the asynchronous operations. This couchbase-promise
library wraps those callback functions with Bluebird promises to provide a convenient, promise-based interface.
Usage
First, install couchbase-promise
as a dependency:
npm install --save couchbase-promise
Then, reference it in your code file:
var Repository = require('couchbase-promise');
Initialize the repository with the connection string and the name of the bucket you want to connect to:
Repository.init('http://localhost:8091', 'default');
Use the static methods of the Repository
class to manage documents stored in your Couchbase database directly by their document identifiers:
createAsync
existsAsync
getAsync
replaceAsync
deleteAsync
You can also use the getViewAsync
method to query a document by a view.
Limitations
- As a static class, currently supports only one connection string and one bucket.
- The views are always updated before reading data from them (
stale
not configurable yet).
Tip: If you find anything that limits the usage of this library for you, feel free the post a new issue and describe it.