vylbot-app/src/database/entities/501231711271780357/Lobby.ts
Vylpes e6c845e3b2
Some checks failed
continuous-integration/drone/push Build is failing
Switch to TypeORM's DataSource API (#299)
- Switch to TypeORM's DataSource API, rather than using the now deprecated ormconfig.json
- This will fix stage deployment not knowing how to deploy the database migrations

#297

> **NOTE:** This change requires the deployment scripts to be updated, please update them on the server before merging

Co-authored-by: Ethan Lane <ethan@vylpes.com>
Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/vylbot-app/pulls/299
2023-05-26 17:59:22 +01:00

44 lines
1.1 KiB
TypeScript

import { Column, Entity } from "typeorm";
import BaseEntity from "../../../contracts/BaseEntity";
import AppDataSource from "../../dataSources/appDataSource";
@Entity()
export default class Lobby extends BaseEntity {
constructor(channelId: string, roleId: string, cooldown: number, name: string) {
super();
this.ChannelId = channelId;
this.RoleId = roleId;
this.Cooldown = cooldown;
this.Name = name;
this.LastUsed = new Date(0);
}
@Column()
public ChannelId: string;
@Column()
public RoleId: string;
@Column()
public Cooldown: number;
@Column()
public LastUsed: Date;
@Column()
public Name: string;
public MarkAsUsed() {
this.LastUsed = new Date();
}
public static async FetchOneByChannelId(channelId: string, relations?: string[]): Promise<Lobby | null> {
const repository = AppDataSource.getRepository(Lobby);
const single = await repository.findOne({ where: { ChannelId: channelId }, relations: relations || [] });
return single;
}
}