"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LocalVideoViewerWatchSectionModel = void 0;
const tslib_1 = require("tslib");
const sequelize_typescript_1 = require("sequelize-typescript");
const local_video_viewer_1 = require("./local-video-viewer");
let LocalVideoViewerWatchSectionModel = class LocalVideoViewerWatchSectionModel extends sequelize_typescript_1.Model {
    static bulkCreateSections(options) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            const { localVideoViewerId, watchSections, transaction } = options;
            const models = [];
            for (const section of watchSections) {
                const model = yield this.create({
                    watchStart: section.start,
                    watchEnd: section.end,
                    localVideoViewerId
                }, { transaction });
                models.push(model);
            }
            return models;
        });
    }
};
tslib_1.__decorate([
    sequelize_typescript_1.CreatedAt,
    tslib_1.__metadata("design:type", Date)
], LocalVideoViewerWatchSectionModel.prototype, "createdAt", void 0);
tslib_1.__decorate([
    (0, sequelize_typescript_1.AllowNull)(false),
    sequelize_typescript_1.Column,
    tslib_1.__metadata("design:type", Number)
], LocalVideoViewerWatchSectionModel.prototype, "watchStart", void 0);
tslib_1.__decorate([
    (0, sequelize_typescript_1.AllowNull)(false),
    sequelize_typescript_1.Column,
    tslib_1.__metadata("design:type", Number)
], LocalVideoViewerWatchSectionModel.prototype, "watchEnd", void 0);
tslib_1.__decorate([
    (0, sequelize_typescript_1.ForeignKey)(() => local_video_viewer_1.LocalVideoViewerModel),
    sequelize_typescript_1.Column,
    tslib_1.__metadata("design:type", Number)
], LocalVideoViewerWatchSectionModel.prototype, "localVideoViewerId", void 0);
tslib_1.__decorate([
    (0, sequelize_typescript_1.BelongsTo)(() => local_video_viewer_1.LocalVideoViewerModel, {
        foreignKey: {
            allowNull: false
        },
        onDelete: 'CASCADE'
    }),
    tslib_1.__metadata("design:type", local_video_viewer_1.LocalVideoViewerModel)
], LocalVideoViewerWatchSectionModel.prototype, "LocalVideoViewer", void 0);
LocalVideoViewerWatchSectionModel = tslib_1.__decorate([
    (0, sequelize_typescript_1.Table)({
        tableName: 'localVideoViewerWatchSection',
        updatedAt: false,
        indexes: [
            {
                fields: ['localVideoViewerId']
            }
        ]
    })
], LocalVideoViewerWatchSectionModel);
exports.LocalVideoViewerWatchSectionModel = LocalVideoViewerWatchSectionModel;
//# sourceMappingURL=local-video-viewer-watch-section.js.map