Add temporary config auto-reload

This commit is contained in:
Dragory 2019-07-22 00:10:54 +03:00
parent 51a9b2bfa5
commit a517ca3906
2 changed files with 64 additions and 0 deletions

View file

@ -28,6 +28,19 @@ export class Configs extends BaseRepository {
});
}
async getHighestId(): Promise<number> {
const rows = await connection.query("SELECT MAX(id) AS highest_id FROM configs");
return (rows.length && rows[0].highest_id) || 0;
}
getActiveLargerThanId(id) {
return this.configs
.createQueryBuilder()
.where("id > :id", { id })
.andWhere("is_active = 1")
.getMany();
}
async hasConfig(key) {
return (await this.getActiveByKey(key)) != null;
}