3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-18 15:45:03 +00:00

Add temporary config auto-reload

This commit is contained in:
Dragory 2019-07-22 00:10:54 +03:00
parent 8d7a937bcd
commit 16a5b5c13a
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;
}