var couchbase = require("couchbase");
var cluster = new couchbase.Cluster('127.0.0.1:8091');
var bucket = cluster.openBucket('beer-sample', function(err) {
if (err) {
throw err;
}
bucket.get('aass_brewery-juleol', function(err, result) {
if (err) {
throw err;
}
var doc = result.value;
console.log(doc.name + ', ABV: ' + doc.abv);
doc.comment = "Random beer from Norway";
bucket.replace('aass_brewery-juleol', doc, function(err, result) {
if (err) {
throw err;
}
console.log(result);
process.exit(0);
});
});
});
Here is my file. It's the example from here : http://docs.couchbase.com/developer/node-2.0/hello-couchbase.html
So when i try to run the server with "nodejs test1.js" i get "Incorrect argument" error.
At bucket.js, module.js and in cluster.js into node_modules/couchbase/lib/
I have installed couchbase and i have full nodejs installed. I'm new in this and i cant understand where is my mistake. Maybe something with the versions of the couchbase or the node version i dunno.
Here is my full error which i get into the terminal:
Error: Incorrect argument
at New Bucket (home/anton/node_modules/couchbase/lib/bucket.js:213:16)
at Object<anonymus> (home/anton/PhpstormProjects/couchbase/test1.js:6:22)
at Cluster.openBucket (home/anton/node_modules/couchbase/lib/cluster.js:37: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:902:3
The "Canonical" format for connecting to a cluster is couchbase://host
where host in your case is localhost
.
Depending on the version you're using, newer enhancements may have been added to allow for the common host:8091
antipattern, but would still be incorrect.
Chances are your code can still work if you upgrade to a newer version - but you should still use the couchbase://
variant (without the port).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.