How to use cas from N1QL query?


#1

The CAS I get from “get()” is an object which contains 2 numbers like that:

   { cas: 
      { '0': 2651848704,
        '1': 1399048988 } 
   }

The CAS I get from a N1QL query like “meta(mybucet”).cas" is one number like that:

18271273968467

When I now want to upsert/replace a document and I give the CAS-Object from the “get()” everything will be fine. But what do I do with the CAS I got from N1QL? How can I use it? Do I simply create my own Object like:

{cas: 18271273968467}

Because of another bug (https://issues.couchbase.com/browse/JSCBC-1951) no matter what I currently supply works, so would be great to know what is actually right.

Thanks!


#2

If somebody else runs into the same problem.
brett19 answered on another thread where I did ask about the same. It seems there is currently no solution but he logged it as a bug here: https://issues.couchbase.com/browse/JSCBC-196


#3

Hey Guys,

Just wanted to let you know that that ticket is now resolved for the latest code available in Git (it will be published in a release on March 3rd). You can now pass string-encoded numbers as a CAS, allowing you to use N1QL values which are returned. Additionally we now support serializing and inspecting the state of CAS values. See here for the changeset: http://review.couchbase.org/#/c/46609/.

Cheers, Brett