How can I get the metadata of a couchbase object in node?


I use a TTL of one month on my users in couchbase and use “touch” to update this TTL every time I see one again within this month.

I need to check the TTL of users to do special actions if they get to old for example.
I cannot use an “updated_at” field in the object since it will not be updated via the touch method, and I prefer using the touch to minimise interaction between services for performance issues.

Can this be done?

Hey @seigneurcanard,

Unfortunately it is not currently possible to reliably fetch the current TTL of an item. The upcoming Couchbase Server release should be able to fetch this information using a new virtual attribute fetch, but this was not yet available in currently released versions. In the meantime, we do suggest performing a subdocument upsert to update a field within the document with an updated timestamp.

Cheers, Brett

1 Like

The N1QL documentation illustrates queries returning a “metrics” object containing the information necessary for paging. I have yet to see this object when running queries via Node using N1QL nor do I see it in the admin console query workbench. Is there a setting or an option I am missing to get the metrics?

Jay G

May I know the status of this Issue , I am running with the same problem. how to set and modify TTL using ottoman by accessing Document metadata expiration field.