ecto_soft_delete
ecto_soft_delete copied to clipboard
[Feature] Restore function
It could be nice to have a function to restore a soft deleted entity.
something like the following code sample in the file https://github.com/revelrylabs/ecto_soft_delete/blob/master/lib/ecto/soft_delete_query.ex
def restore(query) do
update(query, [t], set: [deleted_at: nil])
end
this wont work due to ecto casting nil to utc_datetime_usec raw query is required, fixed in pr #143
We have a functino restore/1
that works nicely
def restore(struct) do
struct
|> Ecto.Changeset.change(%{deleted_at: nil})
|> Repo.update()
end
hmmm i dont see it in the repo nor in the hex.docs, however when i try to nil a datestamp by running restore() as specified above in postgres ecto casts it to now(), i believe this is the default behaviour of ecto for date/time types as i see many discussions about it.
No I mean, we have added this function into our code ^^
I will continue this discussion your PR