]>
Commit | Line | Data |
---|---|---|
6b616860 C |
1 | import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Table } from 'sequelize-typescript' |
2 | import { VideoModel } from './video' | |
3 | import * as Sequelize from 'sequelize' | |
4 | ||
5 | @Table({ | |
6 | tableName: 'videoView', | |
7 | indexes: [ | |
8 | { | |
9 | fields: [ 'videoId' ] | |
0926af7a C |
10 | }, |
11 | { | |
12 | fields: [ 'startDate' ] | |
6b616860 C |
13 | } |
14 | ] | |
15 | }) | |
16 | export class VideoViewModel extends Model<VideoViewModel> { | |
17 | @CreatedAt | |
18 | createdAt: Date | |
19 | ||
20 | @AllowNull(false) | |
21 | @Column(Sequelize.DATE) | |
22 | startDate: Date | |
23 | ||
24 | @AllowNull(false) | |
25 | @Column(Sequelize.DATE) | |
26 | endDate: Date | |
27 | ||
28 | @AllowNull(false) | |
29 | @Column | |
30 | views: number | |
31 | ||
32 | @ForeignKey(() => VideoModel) | |
33 | @Column | |
34 | videoId: number | |
35 | ||
36 | @BelongsTo(() => VideoModel, { | |
37 | foreignKey: { | |
38 | allowNull: false | |
39 | }, | |
40 | onDelete: 'CASCADE' | |
41 | }) | |
42 | Video: VideoModel | |
43 | ||
44 | } |