summary refs log tree commit diff
path: root/src/util/entities/StreamSession.ts
blob: 1dca2424c4bd88dd0f23dfca09f01e4cec746514 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm";
import { BaseClass } from "./BaseClass";
import { User } from "./User";
import { Stream } from "./Stream";

@Entity({
    name: "stream_sessions",
})
export class StreamSession extends BaseClass {
    @Column()
    @RelationId((session: StreamSession) => session.stream)
    stream_id: string;

    @JoinColumn({ name: "stream_id" })
    @ManyToOne(() => Stream, {
        onDelete: "CASCADE",
    })
    stream: Stream;

    @Column()
    @RelationId((session: StreamSession) => session.user)
    user_id: string;

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

    @Column({ nullable: true })
    token: string;

    // this is for gateway session
    @Column()
    session_id: string;

    @Column({ default: false })
    used: boolean;
}