0

I am trying to test couchnode "Couchbase Node.js Client" V2.0.0 but it does not work.

I have a couchbase installed with 2 buckets : default and beer-sample

I follow the README : couchnode

$ npm install couchbase

The example in the README works fine and displays correctly {name: Frank}

but when I launch the example.js, it does not work

I tried config.json empty and configured with

{ "bucket":"default", "host":"127.0.0.1:8091"}

$ node example.js

/home/clodio/node/node_modules/couchbase/example.js:16
bucket = new couchbase.Connection(config, function(err) {
         ^
TypeError: undefined is not a function
    at Object.<anonymous> (/home/clodio/node/node_modules/couchbase/example.js:16:10)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

What's wrong?

Note : I read the Error Connecting to CouchBase from Node.js using Couchnode module v.1.2.4 but it is not the same problem

Community
  • 1
  • 1
clood
  • 27
  • 1
  • 8

2 Answers2

1

From my blog on Node.js and Couchbase http://mycouchbaseblog.blogspot.ie/2014/09/getting-started-with-nodejs-and.html

// load the Couchbase driver and connect to the cluster
var couchbase = require('couchbase');
//no need for parameter if it is localhost
var cluster = new couchbase.Cluster();
var bucket = cluster.openBucket('beer-sample');

//get a record from the database and output the results
bucket.get('new_holland_brewing_company-sundog', function(err, result) {
console.log(result);
 });
-1

"Couchbase Node.js Client" V2.0.0 DOCS here

The following code works , ( there are alot of changes in v2)

var couchbase = require('couchbase')
var cluster = new couchbase.Cluster('couchbase://xx.x.x.x');
var bucket =  cluster.openBucket('users');
bucket.upsert('document_name', {some:'value'}, function(err, res) {
if (err) {
    console.log('operation failed', err);
    return;
}

   console.log('success!', res);
});
doron aviguy
  • 2,554
  • 2
  • 22
  • 18
  • in V2, there is effectively a lot of changes and the sample projects that i was using did nut use the new methods – clood Oct 22 '14 at 07:19