2018-08-29 09:26:25 -05:00
|
|
|
import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Table } from 'sequelize-typescript'
|
|
|
|
import { VideoModel } from './video'
|
|
|
|
import * as Sequelize from 'sequelize'
|
|
|
|
|
|
|
|
@Table({
|
|
|
|
tableName: 'videoView',
|
|
|
|
indexes: [
|
|
|
|
{
|
|
|
|
fields: [ 'videoId' ]
|
2018-09-04 08:25:02 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
fields: [ 'startDate' ]
|
2018-08-29 09:26:25 -05:00
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
export class VideoViewModel extends Model<VideoViewModel> {
|
|
|
|
@CreatedAt
|
|
|
|
createdAt: Date
|
|
|
|
|
|
|
|
@AllowNull(false)
|
|
|
|
@Column(Sequelize.DATE)
|
|
|
|
startDate: Date
|
|
|
|
|
|
|
|
@AllowNull(false)
|
|
|
|
@Column(Sequelize.DATE)
|
|
|
|
endDate: Date
|
|
|
|
|
|
|
|
@AllowNull(false)
|
|
|
|
@Column
|
|
|
|
views: number
|
|
|
|
|
|
|
|
@ForeignKey(() => VideoModel)
|
|
|
|
@Column
|
|
|
|
videoId: number
|
|
|
|
|
|
|
|
@BelongsTo(() => VideoModel, {
|
|
|
|
foreignKey: {
|
|
|
|
allowNull: false
|
|
|
|
},
|
|
|
|
onDelete: 'CASCADE'
|
|
|
|
})
|
|
|
|
Video: VideoModel
|
|
|
|
|
|
|
|
}
|