Add entity

This commit is contained in:
Ethan Lane 2022-07-12 18:36:25 +01:00
parent 4621cec9d5
commit 8890b6f4fa
Signed by: Vylpes
GPG key ID: EED233CC06D12504
2 changed files with 34 additions and 0 deletions

View file

@ -0,0 +1,21 @@
import { Entity, getConnection } from "typeorm";
import BaseEntity from "../contracts/BaseEntity";
@Entity()
export default class IgnoredChannel extends BaseEntity {
constructor(channelId: string) {
super();
this.Id = channelId;
}
public static async IsChannelIgnored(channelId: string): Promise<boolean> {
const connection = getConnection();
const repository = connection.getRepository(IgnoredChannel);
const single = await repository.findOne(channelId);
return single != undefined;
}
}

View file

@ -0,0 +1,13 @@
import { MigrationInterface, QueryRunner } from "typeorm"
export class migration1657647026816 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
queryRunner.query(`CREATE TABLE ignored_channel (Id varchar(255), PRIMARY KEY (Id))`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
queryRunner.query(`DROP TABLE ignored_channel`)
}
}