"use strict";
var VideoSourceModel_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.VideoSourceModel = void 0;
const tslib_1 = require("tslib");
const sequelize_1 = require("sequelize");
const sequelize_typescript_1 = require("sequelize-typescript");
const video_1 = require("./video");
let VideoSourceModel = VideoSourceModel_1 = class VideoSourceModel extends sequelize_typescript_1.Model {
    static loadByVideoId(videoId) {
        return VideoSourceModel_1.findOne({ where: { videoId } });
    }
    toFormattedJSON() {
        return {
            filename: this.filename
        };
    }
};
tslib_1.__decorate([
    sequelize_typescript_1.CreatedAt,
    tslib_1.__metadata("design:type", Date)
], VideoSourceModel.prototype, "createdAt", void 0);
tslib_1.__decorate([
    sequelize_typescript_1.UpdatedAt,
    tslib_1.__metadata("design:type", Date)
], VideoSourceModel.prototype, "updatedAt", void 0);
tslib_1.__decorate([
    (0, sequelize_typescript_1.AllowNull)(false),
    sequelize_typescript_1.Column,
    tslib_1.__metadata("design:type", String)
], VideoSourceModel.prototype, "filename", void 0);
tslib_1.__decorate([
    (0, sequelize_typescript_1.ForeignKey)(() => video_1.VideoModel),
    sequelize_typescript_1.Column,
    tslib_1.__metadata("design:type", Number)
], VideoSourceModel.prototype, "videoId", void 0);
tslib_1.__decorate([
    (0, sequelize_typescript_1.BelongsTo)(() => video_1.VideoModel),
    tslib_1.__metadata("design:type", video_1.VideoModel)
], VideoSourceModel.prototype, "Video", void 0);
VideoSourceModel = VideoSourceModel_1 = tslib_1.__decorate([
    (0, sequelize_typescript_1.Table)({
        tableName: 'videoSource',
        indexes: [
            {
                fields: ['videoId'],
                where: {
                    videoId: {
                        [sequelize_1.Op.ne]: null
                    }
                }
            }
        ]
    })
], VideoSourceModel);
exports.VideoSourceModel = VideoSourceModel;
//# sourceMappingURL=video-source.js.map