3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 04:25:01 +00:00

feat: upgrade to TypeORM 0.3

This commit is contained in:
Dragory 2023-07-01 12:17:45 +00:00
parent 8cee4ec1e4
commit 761ff27771
No known key found for this signature in database
57 changed files with 412 additions and 325 deletions

View file

@ -1,9 +1,9 @@
import { getRepository, Repository } from "typeorm";
import { Repository } from "typeorm";
import { isAPI } from "../globals";
import { HOURS, SECONDS } from "../utils";
import { BaseRepository } from "./BaseRepository";
import { cleanupConfigs } from "./cleanup/configs";
import { connection } from "./db";
import { dataSource } from "./dataSource";
import { Config } from "./entities/Config";
const CLEANUP_INTERVAL = 1 * HOURS;
@ -24,7 +24,7 @@ export class Configs extends BaseRepository {
constructor() {
super();
this.configs = getRepository(Config);
this.configs = dataSource.getRepository(Config);
}
getActiveByKey(key) {
@ -37,7 +37,7 @@ export class Configs extends BaseRepository {
}
async getHighestId(): Promise<number> {
const rows = await connection.query("SELECT MAX(id) AS highest_id FROM configs");
const rows = await dataSource.query("SELECT MAX(id) AS highest_id FROM configs");
return (rows.length && rows[0].highest_id) || 0;
}
@ -62,7 +62,7 @@ export class Configs extends BaseRepository {
}
async saveNewRevision(key, config, editedBy) {
return connection.transaction(async (entityManager) => {
return dataSource.transaction(async (entityManager) => {
const repo = entityManager.getRepository(Config);
// Mark all old revisions inactive
await repo.update({ key }, { is_active: false });