Undelete an entity

Hi folks is there a way to undelete an entity?

We have a use case where we want for an entity to disappear from the queries xt/delete but preserve its history so that we can return to it in case.
It is very important in this use case to preserve history that is why we were looking for something built-in.

Thanks!

As per @refset

there’s no undelete operation, you simply have to scan for the version you want to bring back to life from (e.g.) entity-history and put it back in at the appropriate time

There is certainly some debate worth considering about whether/when to rely on delete for filtering out old data vs using a user-space :state or :deleted? field and doing the work as part of the joins. It depends on what your full range of queries are (since searching over time isn’t supported within XT’s Datalog today)

As a follow-up, for clarification, it’s also worth noting that when you :xt/delete and then :xt/put with the same :xt/id, you end up adding back to the previous entity history, since entities are correlated by ID. The entity-history will show everything that uses the same ID.

1 Like