Stale parameter in N1QL

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.

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.

1 Like

I’m currently using NodeJS SDK

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

1 Like

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