How do I store temporary data in hasura/my postgresql database? My usecase is for verificaion codes during onboarding (for example, email) which I don't want to have afterwards in the schema. (otherwise I'd have verification_x, verification_y, etc etc etc)
Asked
Active
Viewed 222 times
0
-
What do you mean by "temporary"? If it is not related to your other data, make a new schema for that. – Vesa Karjalainen Mar 19 '22 at 10:12
-
As in, like a verification code that will be used once and then never needed again. – Sasial Mar 19 '22 at 10:48
-
In some cases, temporary means "milliseconds" and during same session, in that case use a variable or maybe a temporary table. But if you send verification codes by email, that could be a week, in that case you put it in a table. – Vesa Karjalainen Mar 19 '22 at 11:03
-
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Mar 20 '22 at 06:29
1 Answers
0
This is more of a DB feature than a hasura thing.
The short answer is, no. This is not a feature of Postgres or Hasura. You can implement it relatively easily if you need to.
See this answer for a Postgres trigger based solution and for a comment downvoting this idea. Hasura also has event triggers if you are more comfortable using a language like python or JS to implement this logic. Basically, an expiration (timestamp) column will allow you to determine when a record is expired. If (or how often) you choose to physically query and delete the expired records is your decision.

Abraham Labkovsky
- 1,771
- 6
- 12