3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-13 21:35:02 +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, In, InsertResult, Repository } from "typeorm";
import { In, InsertResult, Repository } from "typeorm";
import { Queue } from "../Queue";
import { chunkArray } from "../utils";
import { BaseGuildRepository } from "./BaseGuildRepository";
import { CaseTypes } from "./CaseTypes";
import { connection } from "./db";
import { dataSource } from "./dataSource";
import { Case } from "./entities/Case";
import { CaseNote } from "./entities/CaseNote";
@ -15,8 +15,8 @@ export class GuildCases extends BaseGuildRepository {
constructor(guildId) {
super(guildId);
this.cases = getRepository(Case);
this.caseNotes = getRepository(CaseNote);
this.cases = dataSource.getRepository(Case);
this.caseNotes = dataSource.getRepository(CaseNote);
this.createQueue = new Queue();
}
@ -30,7 +30,7 @@ export class GuildCases extends BaseGuildRepository {
});
}
async find(id: number): Promise<Case | undefined> {
async find(id: number): Promise<Case | null> {
return this.cases.findOne({
relations: this.getRelations(),
where: {
@ -40,7 +40,7 @@ export class GuildCases extends BaseGuildRepository {
});
}
async findByCaseNumber(caseNumber: number): Promise<Case | undefined> {
async findByCaseNumber(caseNumber: number): Promise<Case | null> {
return this.cases.findOne({
relations: this.getRelations(),
where: {
@ -50,7 +50,7 @@ export class GuildCases extends BaseGuildRepository {
});
}
async findLatestByModId(modId: string): Promise<Case | undefined> {
async findLatestByModId(modId: string): Promise<Case | null> {
return this.cases.findOne({
relations: this.getRelations(),
where: {
@ -63,7 +63,7 @@ export class GuildCases extends BaseGuildRepository {
});
}
async findByAuditLogId(auditLogId: string): Promise<Case | undefined> {
async findByAuditLogId(auditLogId: string): Promise<Case | null> {
return this.cases.findOne({
relations: this.getRelations(),
where: {
@ -88,7 +88,7 @@ export class GuildCases extends BaseGuildRepository {
where: {
guild_id: this.guildId,
mod_id: modId,
is_hidden: 0,
is_hidden: false,
},
});
}
@ -99,7 +99,7 @@ export class GuildCases extends BaseGuildRepository {
where: {
guild_id: this.guildId,
mod_id: modId,
is_hidden: 0,
is_hidden: false,
},
skip,
take: count,
@ -181,7 +181,7 @@ export class GuildCases extends BaseGuildRepository {
}
async softDelete(id: number, deletedById: string, deletedByName: string, deletedByText: string) {
return connection.transaction(async (entityManager) => {
return dataSource.transaction(async (entityManager) => {
const cases = entityManager.getRepository(Case);
const caseNotes = entityManager.getRepository(CaseNote);