I'm trying to run some N1QL queries using couchbase
npm package. Here's the steps I took before running the code:
- Installed and executed Couchbase on OSX
- Navigated to :8091 and set up the credentials as well as the
beer-sample
bucket - Downloaded the N1QL DP4 to a folder Enabled
cbq-engine
like so:./cbq-engine -datastore=http://localhost:8091
- Created a primary index as per the documentation
At this point I have localhost:8091
(primary Couchbase cluster) and localhost:8093
(DP4 engine) both live.
Here's the code I'm using from the node.js client to try to run a simple N1QL query:
var colors = require('colors'); // for console.log
var couchbase = require('couchbase');
var N1qlQuery = require('couchbase').N1qlQuery; // get query object
var myCluster = new couchbase.Cluster('couchbase://localhost:8091'); // connect to live local cluster
var myBucket = myCluster.openBucket(); // open bucket
myBucket.enableN1ql(['http://localhost:8093/']); // enable n1ql as per documentation (http://ift.tt/1yMdQW0) - I also tried :8091, same result
var query = N1qlQuery.fromString('SELECT * FROM `beer-sample` LIMIT 10');
setTimeout(function() {
myBucket.query(query, function(err, res) {
if (err) {
console.log('query failed'.red, err);
return;
}
console.log('success!', res);
});
}, 2000); // just in case connecting takes a second or something?
Here's the result:
query failed { [Error: failed to connect to bucket] code: 24 }
I've tried seemingly everything and I can't find any documentation to troubleshoot this. What's going on?
Aucun commentaire:
Enregistrer un commentaire