I feel a little strange asking this question, but I really have not been able to find an answer after pretty extensive googling.
Right now I'm using the peewee ORM on top of PostgresQL and I'm implementing a password reset. For obvious reasons I don't want to keep the password-reset keys around forever, so I'd like to create the object in postgres and have it expire after a set amount of time.
I can't find any mention of how to do this in the docs or on StackOverflow. This seems like a pretty common use case, but it seems that there isn't anything out there on how to actually do this. My model for reference:
class PostgresModel(Model):
_id = PrimaryKeyField()
class Meta:
database = DATABASE
@classmethod
def create_and_commit(cls, **kwargs):
cls.create(**kwargs)
DATABASE.commit()
class ForgotPassword(PostgresModel):
user = ForeignKeyField(BaseUser, related_name='password_reset')
secret_key = CharField()
Anyone have insight on this?