]>
Commit | Line | Data |
---|---|---|
d95d1559 | 1 | import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Model, Table, UpdatedAt } from 'sequelize-typescript' |
6b5f72be | 2 | import { AttributesOnly } from '@shared/typescript-utils' |
d95d1559 C |
3 | import { VideoDetails } from '@shared/models' |
4 | import { VideoModel } from '../video/video' | |
5 | import { AbuseModel } from './abuse' | |
6 | ||
7 | @Table({ | |
8 | tableName: 'videoAbuse', | |
9 | indexes: [ | |
10 | { | |
11 | fields: [ 'abuseId' ] | |
12 | }, | |
13 | { | |
14 | fields: [ 'videoId' ] | |
15 | } | |
16 | ] | |
17 | }) | |
16c016e8 | 18 | export class VideoAbuseModel extends Model<Partial<AttributesOnly<VideoAbuseModel>>> { |
d95d1559 C |
19 | |
20 | @CreatedAt | |
21 | createdAt: Date | |
22 | ||
23 | @UpdatedAt | |
24 | updatedAt: Date | |
25 | ||
26 | @AllowNull(true) | |
27 | @Default(null) | |
28 | @Column | |
29 | startAt: number | |
30 | ||
31 | @AllowNull(true) | |
32 | @Default(null) | |
33 | @Column | |
34 | endAt: number | |
35 | ||
36 | @AllowNull(true) | |
37 | @Default(null) | |
38 | @Column(DataType.JSONB) | |
39 | deletedVideo: VideoDetails | |
40 | ||
41 | @ForeignKey(() => AbuseModel) | |
42 | @Column | |
43 | abuseId: number | |
44 | ||
45 | @BelongsTo(() => AbuseModel, { | |
46 | foreignKey: { | |
47 | allowNull: false | |
48 | }, | |
49 | onDelete: 'cascade' | |
50 | }) | |
51 | Abuse: AbuseModel | |
52 | ||
53 | @ForeignKey(() => VideoModel) | |
54 | @Column | |
55 | videoId: number | |
56 | ||
57 | @BelongsTo(() => VideoModel, { | |
58 | foreignKey: { | |
59 | allowNull: true | |
60 | }, | |
61 | onDelete: 'set null' | |
62 | }) | |
63 | Video: VideoModel | |
64 | } |