1 import { Transaction } from 'sequelize'
2 import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Table } from 'sequelize-typescript'
3 import { MLocalVideoViewerWatchSection } from '@server/types/models'
4 import { AttributesOnly } from '@shared/typescript-utils'
5 import { LocalVideoViewerModel } from './local-video-viewer'
8 tableName: 'localVideoViewerWatchSection',
12 fields: [ 'localVideoViewerId' ]
16 export class LocalVideoViewerWatchSectionModel extends Model<Partial<AttributesOnly<LocalVideoViewerWatchSectionModel>>> {
28 @ForeignKey(() => LocalVideoViewerModel)
30 localVideoViewerId: number
32 @BelongsTo(() => LocalVideoViewerModel, {
38 LocalVideoViewer: LocalVideoViewerModel
40 static async bulkCreateSections (options: {
41 localVideoViewerId: number
46 transaction?: Transaction
48 const { localVideoViewerId, watchSections, transaction } = options
49 const models: MLocalVideoViewerWatchSection[] = []
51 for (const section of watchSections) {
52 const model = await this.create({
53 watchStart: section.start,
54 watchEnd: section.end,