Get TTL value in seconds


#1

How can I get TTL of document when

  • I use lookupIn
  • I use get

#2

Any idea? Is it possible?


#3

Hey @socketman2016,

It is unfortunately not possible to fetch the TTL of the document when performing a standard get operation, as this is usually maintained as internal state only. It is however possible to fetch the expiry using our subdocument API.

Something like this should work:

bucket.lookupIn('my_document')
  .get('$document.exptime', {xattrMacro: true})
  .execute((error, result) =>{
    // ...
});

Cheers, Brett