2023-07-01 12:17:45 +00:00
|
|
|
import { Repository } from "typeorm";
|
2021-09-25 21:53:48 +03:00
|
|
|
import { BaseRepository } from "./BaseRepository";
|
2023-07-01 12:17:45 +00:00
|
|
|
import { dataSource } from "./dataSource";
|
2023-04-01 12:58:17 +01:00
|
|
|
import { ArchiveEntry } from "./entities/ArchiveEntry";
|
2021-09-25 21:53:48 +03:00
|
|
|
|
|
|
|
export class Archives extends BaseRepository {
|
|
|
|
protected archives: Repository<ArchiveEntry>;
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
2023-07-01 12:17:45 +00:00
|
|
|
this.archives = dataSource.getRepository(ArchiveEntry);
|
2021-09-25 21:53:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public deleteExpiredArchives() {
|
|
|
|
this.archives
|
|
|
|
.createQueryBuilder()
|
|
|
|
.andWhere("expires_at IS NOT NULL")
|
|
|
|
.andWhere("expires_at <= NOW()")
|
|
|
|
.delete()
|
|
|
|
.execute();
|
|
|
|
}
|
|
|
|
}
|