Let's say there is a schema:
schema "players" do
:key, :string
:reset_key_token, :string
end
A hash is set in the :reset_key_token
field when the user wants to reset their key. The idea is that the :reset_key_token
should be put back to nil
say, after a week the token was set. My question is:
Is there a standard way to expire the value of an Ecto Schema?
I have been looking for some time now, but haven't found anything on the subject yet. However, I found this MySQL question and thought of following the same idea:
1.- Add a :reset_key_token_expires, Ecto.DateTime
to the schema.
2.- Before a read (in my case I need it also before a write), check :reset_key_token_expires
and set it to nil
if the time has passed.
But I would like to see if anyone that has done this before could provide some answers first.
Thanks for the help!