40021-vm/backend/src/db/models/video_topic_mappings.js
2026-05-16 14:56:10 +00:00

113 lines
1.6 KiB
JavaScript

const config = require('../../config');
const providers = config.providers;
const crypto = require('crypto');
const bcrypt = require('bcrypt');
const moment = require('moment');
module.exports = function(sequelize, DataTypes) {
const video_topic_mappings = sequelize.define(
'video_topic_mappings',
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
alignment_strength: {
type: DataTypes.ENUM,
values: [
"direct",
"partial",
"inspiration"
],
},
alignment_notes: {
type: DataTypes.TEXT,
},
importHash: {
type: DataTypes.STRING(255),
allowNull: true,
unique: true,
},
},
{
timestamps: true,
paranoid: true,
freezeTableName: true,
},
);
video_topic_mappings.associate = (db) => {
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
//end loop
db.video_topic_mappings.belongsTo(db.videos, {
as: 'video',
foreignKey: {
name: 'videoId',
},
constraints: false,
});
db.video_topic_mappings.belongsTo(db.syllabus_topics, {
as: 'syllabus_topic',
foreignKey: {
name: 'syllabus_topicId',
},
constraints: false,
});
db.video_topic_mappings.belongsTo(db.users, {
as: 'createdBy',
});
db.video_topic_mappings.belongsTo(db.users, {
as: 'updatedBy',
});
};
return video_topic_mappings;
};