39521-vm/backend/src/db/models/seo_entries.js
2026-04-08 17:10:40 +00:00

146 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 seo_entries = sequelize.define(
'seo_entries',
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
entity_type: {
type: DataTypes.ENUM,
values: [
"page",
"event",
"memory"
],
},
entity_slug: {
type: DataTypes.TEXT,
},
canonical_url: {
type: DataTypes.TEXT,
},
meta_title: {
type: DataTypes.TEXT,
},
meta_description: {
type: DataTypes.TEXT,
},
meta_robots: {
type: DataTypes.TEXT,
},
importHash: {
type: DataTypes.STRING(255),
allowNull: true,
unique: true,
},
},
{
timestamps: true,
paranoid: true,
freezeTableName: true,
},
);
seo_entries.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.seo_entries.hasMany(db.file, {
as: 'structured_data_json',
foreignKey: 'belongsToId',
constraints: false,
scope: {
belongsTo: db.seo_entries.getTableName(),
belongsToColumn: 'structured_data_json',
},
});
db.seo_entries.belongsTo(db.users, {
as: 'createdBy',
});
db.seo_entries.belongsTo(db.users, {
as: 'updatedBy',
});
};
return seo_entries;
};