Partypack/Server/Source/Schemas/User.ts

29 lines
813 B
TypeScript
Raw Normal View History

2024-01-24 01:35:47 +01:00
import { BaseEntity, Column, Entity, JoinTable, ManyToMany, OneToMany, PrimaryColumn } from "typeorm";
import { Song } from "./Song";
2024-01-24 01:35:47 +01:00
import { Rating } from "./Rating";
2024-01-26 23:29:46 +01:00
export enum UserPermissions { // increments of 100 in case we want to add permissions inbetween without fucking up all instances
User = 100,
VerifiedUser = 200,
Moderator = 300,
Administrator = 400
}
@Entity()
export class User extends BaseEntity {
@PrimaryColumn()
ID: string;
@Column({ type: "simple-json" })
Library: { SongID: string, Overriding: string }[];
2024-01-26 23:29:46 +01:00
@Column({ default: UserPermissions.User })
PermissionLevel: UserPermissions;
2024-01-24 01:35:47 +01:00
@OneToMany(() => Rating, R => R.Author)
Ratings: Rating[];
@ManyToMany(() => Song, { eager: true })
@JoinTable()
BookmarkedSongs: Song[];
}