/
Channel.entity.ts
67 lines (53 loc) · 1.58 KB
/
Channel.entity.ts
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import {
Column,
Entity,
JoinColumn,
JoinTable,
ManyToMany,
ManyToOne,
OneToMany,
} from 'typeorm';
import { PostSettings } from 'types/PostSettings';
import { RecordEntity } from './base/RecordEntity';
import { UserChannel } from './UserChannel.entity';
import { User } from './User.entity';
import { Zone } from './Zone.entity';
import { defaultPostSettings } from './data/default-post-settings';
@Entity()
export class Channel extends RecordEntity {
@Column()
name: string;
@Column({ nullable: true })
description: string;
@Column({ default: true })
active: boolean;
@Column({ default: false })
public: boolean;
@ManyToOne(() => User, { onDelete: 'SET NULL' })
@JoinColumn({ name: 'createdById' })
createdBy: User;
@Column('uuid')
createdById: string;
@Column({ nullable: true })
displayPhoto: string;
@Column({ nullable: true })
backgroundPhoto: string;
@ManyToOne(() => Zone, (zone) => zone.channels, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'zoneId' })
zone: Zone;
@Column('uuid')
zoneId: string;
@OneToMany(() => UserChannel, (userChannel) => userChannel.channel)
userChannel: Array<UserChannel>;
@ManyToMany(() => User, (user) => user.zones)
@JoinTable({
name: 'user_channel',
joinColumn: { name: 'channelId', referencedColumnName: 'id' },
inverseJoinColumn: { name: 'userId', referencedColumnName: 'id' },
})
users: Array<User>;
@Column('tsvector', { select: false })
search_document: any;
@Column({ type: 'simple-json', select: false, default: defaultPostSettings })
postSettings: PostSettings;
}