fix TypeORM error from MetaService.fetch

This commit is contained in:
Hazelnoot 2025-05-25 18:42:47 -04:00
parent 070084889f
commit 4738b14d1c

View file

@ -74,11 +74,13 @@ export class MetaService implements OnApplicationShutdown {
if (!noCache && this.cache) return this.cache; if (!noCache && this.cache) return this.cache;
// 過去のバグでレコードが複数出来てしまっている可能性があるので新しいIDを優先する // 過去のバグでレコードが複数出来てしまっている可能性があるので新しいIDを優先する
let meta = await this.metasRepository.findOne({ let meta = await this.metasRepository.createQueryBuilder('meta')
order: { .select()
.orderBy({
id: 'DESC', id: 'DESC',
}, })
}); .limit(1)
.getOne();
if (!meta) { if (!meta) {
await this.metasRepository.createQueryBuilder('meta') await this.metasRepository.createQueryBuilder('meta')
@ -89,11 +91,13 @@ export class MetaService implements OnApplicationShutdown {
.orIgnore() .orIgnore()
.execute(); .execute();
meta = await this.metasRepository.findOneOrFail({ meta = await this.metasRepository.createQueryBuilder('meta')
order: { .select()
.orderBy({
id: 'DESC', id: 'DESC',
}, })
}); .limit(1)
.getOneOrFail();
} }
this.cache = meta; this.cache = meta;