n1ql query causes error node.js


#1

I am writing a rest application to use on top of couchbase4
i am trying to use n1ql but even running the example i am getting a not good error that seems to kill the application

in my console i see the node.js app spit out:
testn1ql id:0 exited with code SIGSEGV

Here is the code, its basically taken from one of the n1ql samples:

var couchbase = require(‘couchbase’);

var myCluster = new couchbase.Cluster(‘couchbase://192.168.33.105’);

var N1qlQuery = require(‘couchbase’).N1qlQuery;
var myBucket = myCluster.openBucket();
myBucket.enableN1ql([‘http://192.168.33.105:8093/’]);
var query = N1qlQuery.fromString(‘SELECT * FROM default’);
myBucket.query(query, function(err, res) {
if (err) {
console.log(“query failed”, err);
return;
}
console.log(“success!”, res);
});


#2

Hey @jysf,

If you’re using Couchbase 4.0 and the latest Node.js SDK, you don’t need to use the following line:

myBucket.enableN1ql(['http://192.168.33.105:8093/']);

Also try dropping couchbase:// from the new couchbase.Cluster function.

If you’re interested in a full working tutorial, I did a blog post here:

http://blog.couchbase.com/making-a-game-api-server-using-nodejs-revisited

Let me know if this helps resolve your issue.

Best,


#3

Yes, thank you very much!!!

And your blog post is very helpful! i wish i found that before :smile:

Sorry if this is an additional unrelated question:
Is there a good blog post or document that describes setting up couchbase in a development environment?
I am running it on a VirtualBox ubuntu 14, but it is not always very happy

Thanks again !
Jason


#4

Hey @jysf,

If you’re just using a single node, I personally just install it on my local machine because Couchbase is very lightweight. If you’re looking for non-local or multi-node solutions, there are AWS images available for quick deployment.

Reach out if you need anything else :slight_smile: