summary refs log tree commit diff
path: root/util/src/entities/Relationship.ts
blob: 3e1280c7e8c467e7a9a10815e22a000f42c8e8f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { Column, Entity, JoinColumn, ManyToOne, OneToMany, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass";
import { User } from "./User";

export enum RelationshipType {
	outgoing = 4,
	incoming = 3,
	blocked = 2,
	friends = 1,
}

@Entity("relationships")
export class Relationship extends BaseClass {
	@RelationId((relationship: Relationship) => relationship.user)
	user_id: string;

	@JoinColumn({ name: "user_id" })
	@ManyToOne(() => User, (user: User) => user.id)
	user: User;

	@Column()
	nickname?: string;

	@Column({ type: "simple-enum", enum: RelationshipType })
	type: RelationshipType;
}