summary refs log tree commit diff
path: root/util/src/entities/Relationship.ts
blob: cf3624bf2fb6ebf2d11c8b0524b4d62fb834b20c (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, 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.relationships)
	user: User;

	@Column({ nullable: true })
	nickname?: string;

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