Reputation: 2025
i've learned couchdb for a year... i've tried bigcouch too...
now i want to try couchbase, i've studied it 2 days, but i still don't know how to access couchbase from couchdb REST API (using NODEJS)...
i've tried to searching on google how to access couchbase, and i got this answer
var memcache = require('./node-memcache'); var client = new memcache.Client(11211,'localhost') client.on('connect',function(){ console.log("connect to memcache\n\n"); client.version(function(error,result){ console.log(error?error:result); client.close(); }) }) client.on('timeout',function(){ console.log('connection timeout'); }) client.on('error',function(e){ console.log(e); }) client.connect();
i think the sample above is not access couchbase directly, but i access memcache.. is there any sample code about how to access couchbase via couchdb REST API...? i'm sorry my english bad
Upvotes: 3
Views: 3439
Reputation: 8063
There's an asynchronous library called 'baseview' to access views and the REST API from Couchbase. It's derived from the CouchDB library 'nano' and quite easy to get data from the views etc.
npm install baseview
baseview = require('baseview')('http://127.0.0.1:8092')
baseview.view('design_doc', 'view_name', function(error, data) {
console.log(error, data);
});
Upvotes: 1
Reputation: 1894
Couchbase Server 2.0 has only the HTTP REST interface for views, not for document CRUD operations.
The best approach would be to use one of the client libraries posted at http://www.couchbase.com/develop
On node.js, there's been some recent discussion on the mailing lists and there is some info on the wiki. Summary is, there is a prototype client library for node.js, but it's not complete/ready.
Upvotes: 1