Can someone please advise how to use the Consistency and REQUEST_PLUS ? In the 2.X SDK that was simple but a lot of things changed and are not very well documented.
Below is my old 2.x aproach
const N1qlQuery = couchbase.N1qlQuery
let statement = N1QLQuery.fromString(queryStr)
statement.consistency(N1QLQuery.Consistency.REQUEST_PLUS)
var result = await cluster.query(statement, id)
console.log(result)
in 3.x it should look something like this but {scanConsistency : RequestPlus} is not valid
var result = await cluster.query(queryStr,id , {scanConsistency : RequestPlus})
Thanks that value at least gets me in the right direction and is for sure missing in the docs.
Now when i use var result = await cluster.query(queryStr,id ,{scanConsistency : couchbase.QueryScanConsistency.RequestPlus})
i get the result as expected but also the folowing error
(node:14752) UnhandledPromiseRejectionWarning: TypeError: callback is not a function
at C:\Users\Alex Ponnath\Documents\GitHub\New-Couchbase\node_modules\couchbase\lib\promisehelper.js:79:25
(node:14752) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14752) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
when i remove the {scanConsistency : couchbase.QueryScanConsistency.RequestPlus} from the code it completes and returns also the data without the error ? Any reason for this behavior ?
Hey @aponnath,
It looks like there is an issue where the callback function is being invoked in spite of the fact that you have not specified one, though looking at the code, this case is guarded against. I’ll have to take a look and see what’s going on, I’ve opened an issue to track this: Loading... .
Cheers, Brett
Sorry, I completely missed that you were passing an id parameter to you query call. This would be the correct code to do that with the new API of the 3.0 SDKs:
var result = await cluster.query(queryStr, {
scanConsistency: couchbase.QueryScanConsistency.RequestPlus,
parameters: [id],
});