Update doc TTL

In the create method there’s ttl param that sets when the doc will be auto-removed.
However, the update method does not have his param.

Is it not possible to update a document’s TTL, or is it just not documented? (hoping for the later)

Hi @danbars,

Yes, it is possible with the same syntax as Create() :

Create(Collection("temp"),{data:{val1:1},ttl:TimeAdd(Now(),10,'days')})
{ ref: Ref(Collection("temp"), "285508976462791175"),
  ts: 1608541427960000,
  data: { val1: 1 },
  ttl: Time("2020-12-31T09:03:47.732886Z") }
> 
Get(Ref(Collection("temp"), "285508976462791175"))
{ ref: Ref(Collection("temp"), "285508976462791175"),
  ts: 1608541427960000,
  data: { val1: 1 },
  ttl: Time("2020-12-31T09:03:47.732886Z") }
> 
> Update(Ref(Collection("temp"), "285508976462791175"),{data:{val2:2},ttl:TimeAdd(Now(),20,'days')})
{ ref: Ref(Collection("temp"), "285508976462791175"),
  ts: 1608541473960000,
  data: { val1: 1, val2: 2 },
  ttl: Time("2021-01-10T09:04:33.764148Z") }

I’ll file a ticket to fix the documentation.
Thanks for reporting!

Luigi

1 Like