2024-01-24 01:35:47 +01:00
|
|
|
import { BaseEntity, Column, Entity, JoinTable, ManyToMany, OneToMany, PrimaryColumn } from "typeorm";
|
2024-01-22 23:04:46 +01:00
|
|
|
import { Song } from "./Song";
|
2024-01-24 01:35:47 +01:00
|
|
|
import { Rating } from "./Rating";
|
2024-01-22 23:04:46 +01:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-01-22 23:04:46 +01:00
|
|
|
@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[];
|
|
|
|
|
2024-01-22 23:04:46 +01:00
|
|
|
@ManyToMany(() => Song, { eager: true })
|
|
|
|
@JoinTable()
|
|
|
|
BookmarkedSongs: Song[];
|
|
|
|
}
|