vylbot-app/src/database/entities/Server.ts
Ethan Lane 5f054b02a5
All checks were successful
continuous-integration/drone/push Build is passing
Add cache helper to update user cache every 30 minutes
2024-03-01 18:25:24 +00:00

35 lines
823 B
TypeScript

import { Column, Entity, OneToMany } from "typeorm";
import BaseEntity from "../../contracts/BaseEntity";
import Role from "./Role";
import Setting from "./Setting";
@Entity()
export default class Server extends BaseEntity {
constructor(serverId: string) {
super();
this.Id = serverId;
this.LastCached = new Date();
}
@Column({ default: "2024-03-01 18:10:04" })
LastCached: Date;
@OneToMany(() => Setting, x => x.Server)
Settings: Setting[];
@OneToMany(() => Role, x => x.Server)
Roles: Role[];
public UpdateLastCached(lastCached: Date) {
this.LastCached = lastCached;
}
public AddSettingToServer(setting: Setting) {
this.Settings.push(setting);
}
public AddRoleToServer(role: Role) {
this.Roles.push(role);
}
}