Ошибка подключения к CouchBase из Node.js с помощью модуля Couchnode v.2.0.0

Я пытаюсь протестировать couchnode "Couchbase Node.js Client" V2.0.0, но он не работает.

У меня установлена база с двумя ведрами: по умолчанию и образец пива

Я следую за README: couchnode

$ npm install couchbase

Пример в README работает нормально и отображается правильно {name: Frank}

но когда я запускаю example.js, он не работает

Я попробовал config.json пустой и настроил

{ "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

В чем дело?

Примечание. Я прочитал сообщение об ошибке подключения к CouchBase из Node.js с помощью модуля Couchnode v.1.2.4, но это не та проблема

2 ответа

Решение

"Couchbase Node.js Client" V2.0.0 DOCS здесь

Следующий код работает, (есть много изменений в 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);
});

Из моего блога на Node.js и 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);
 });
Другие вопросы по тегам