HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Couchbase - Get document creation date

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
dategetcouchbasedocumentcreation

Problem

Is there a way we can get a document's creation date in Couchbase (2.2.0).

We are currently not storing creation date in our documents, so wanted to know if couch stores that as part of document meta data.

We plan to query documents based on time, and currently the only option that we think will work is to change the server code to store additional creation date field as part of the document itself.

Solution

It is not tracked but if you have not modified the document since create you can use the CAS value (as of version 4.6), converted to a timestamp.

e.g. using N1QL:
SELECT meta().cas/1000000000 ... -> gives seconds

Context

StackExchange Database Administrators Q#77108, answer score: 2

Revisions (0)

No revisions yet.