vylbot-app/src/entity/Setting.ts
Vylpes 39999dfbba 3.0.7 (#295)
- Update dependency minimatch to 3.1.1
- Update dependency xml2js

Co-authored-by: Ethan Lane <ethan@vylpes.com>
Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/vylbot-app/pulls/295
Reviewed-by: VylpesTester <tester@vylpes.com>
2023-05-08 18:24:09 +01:00

37 lines
926 B
TypeScript

import { Column, Entity, getConnection, ManyToOne } from "typeorm";
import BaseEntity from "../contracts/BaseEntity";
import Server from "./Server";
@Entity()
export default class Setting extends BaseEntity {
constructor(key: string, value: string) {
super();
this.Key = key;
this.Value = value;
}
@Column()
Key: string;
@Column()
Value: string;
@ManyToOne(() => Server, x => x.Settings)
Server: Server;
public UpdateBasicDetails(key: string, value: string) {
this.Key = key;
this.Value = value;
}
public static async FetchOneByKey(key: string, relations?: string[]): Promise<Setting | null> {
const connection = getConnection();
const repository = connection.getRepository(Setting);
const single = await repository.findOne({ where: { Key: key }, relations: relations || {} });
return single;
}
}