Stale parameter in N1QL


#1

Hi, I noticed that N1QL uses ‘stale=ok’ on queries. How can I set the stale parameter to false? I want to have the maximum consistency available, without spending a bunch of seconds to see my data updated.


#2

Which client SDK are you using? The N1QL REST API provides a scan_consistency parameter, so it’s a matter of making sure your client SDK uses or exposes this.


#3

I’m currently using NodeJS SDK


#4

Hey donadev,

Here is an example of specifying the scan consistency for a query:

var N1qlQuery = require('couchbase').N1qlQuery;
...
var q = N1qlQuery.fromString('SELECT * FROM default').consistency(N1qlQuery.Consistency.REQUEST_PLUS);
bucket.query(q, function(err, rows) {
   ...
});

Cheers, Brett


#5

Thank you very much!
A little correction: while I was looking in the SDK’s source code, I noticed that the REQUEST_PLUS value is obtained using:
N1qlQuery.Consistency.REQUEST_PLUS