Hi,
I am using latest sdk and I can’t find any documentation about document metadatas. Can you help ?
How to get cas ? What I get is CouchbaseCas<7062207165670359040> an opaque and obscure structure
Where is the meta.rev attribute ?
Thanks,
Cyril
nraboy
2
Hey @clakech,
What version of Couchbase Server are you using?
Best,
Now we are using 3.x but we may switch to 4.x soon, so both
nraboy
4
Hey @clakech,
With 4.x you can leverage the power of N1QL to get meta information about your documents. For example, you can run the following:
SELECT META(mybucket) FROM bucket-name-here
mybucket;
That will return the following results:
[
{
"$1": {
"cas": 5.4445395017728e+13,
"flags": 0,
"id": "doc-id-1",
"type": "json"
}
},
{
"$1": {
"cas": 5.4445405765632e+13,
"flags": 0,
"id": "doc-id-2",
"type": "json"
}
}
]
Based on that information you can narrow your query like so:
SELECT META(mybucket).cas FROM `bucket-name-here` mybucket;
That would return only the CAS information about a document.
Otherwise, when you get documents from a lookup or ViewQuery you should be able to do result.cas
where result is the particular document returned.
Let me know if this helps.
Best,
1 Like