38933-vm/backend/src/db/models/about_sections.js
2026-03-02 13:42:18 +00:00

130 lines
1.7 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 about_sections = sequelize.define(
'about_sections',
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
headline: {
type: DataTypes.TEXT,
},
body_text: {
type: DataTypes.TEXT,
},
highlight_badge_text: {
type: DataTypes.TEXT,
},
average_rating: {
type: DataTypes.DECIMAL,
},
review_count: {
type: DataTypes.INTEGER,
},
is_visible: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
},
importHash: {
type: DataTypes.STRING(255),
allowNull: true,
unique: true,
},
},
{
timestamps: true,
paranoid: true,
freezeTableName: true,
},
);
about_sections.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.about_sections.hasMany(db.file, {
as: 'team_images',
foreignKey: 'belongsToId',
constraints: false,
scope: {
belongsTo: db.about_sections.getTableName(),
belongsToColumn: 'team_images',
},
});
db.about_sections.belongsTo(db.users, {
as: 'createdBy',
});
db.about_sections.belongsTo(db.users, {
as: 'updatedBy',
});
};
return about_sections;
};