feat(auth): add session traces cleanup procedure

This commit is contained in:
Karol Sójko
2022-12-19 12:49:59 +01:00
parent c12d354900
commit 147d8fd9af
10 changed files with 95 additions and 0 deletions
@@ -10,6 +10,14 @@ export class MySQLSessionTraceRepository implements SessionTraceRepositoryInterf
private mapper: MapperInterface<SessionTrace, TypeORMSessionTrace>,
) {}
async removeExpiredBefore(date: Date): Promise<void> {
await this.ormRepository
.createQueryBuilder()
.delete()
.where('expires_at < :date', { date: date.toISOString() })
.execute()
}
async findOneByUserUuidAndDate(userUuid: Uuid, date: Date): Promise<SessionTrace | null> {
const typeOrm = await this.ormRepository
.createQueryBuilder('trace')