Dealing with document metadata

How can I retrieve a document metadata? With Bucket#get I can only get its value

Is there any function in the SDK that can convert a document CAS number into the REV string value and the other way around?

So far my poor man solution is having a view with all document ids as key, and their meta as value. Or might it be that this is how it must be done?

1 Answer

« Back to question.

The CAS value and the rev are not related so they can't be transformed into each other, also the rev should not be used by your application since it is only used internally to track changes for XDCR. In the docs on More on meta data see Sequence number for more.

The meta data is only exposed to the view engine so accessing it only works via a view as well, to get access to CAS etc. you would use

val, flags, cas = c.get(:bar, extended: true)

They are related, but only one way. I.e. you can extract cas from rev, but you cannot build rev number, because of its suffix "....-N", where N is kind of number of modifications of that key