32955/backend/src/db/models/tactics.js
2025-07-21 14:53:17 +00:00

76 lines
1.4 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 tactics = sequelize.define(
'tactics',
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
title: {
type: DataTypes.TEXT,
},
description: {
type: DataTypes.TEXT,
},
game: {
type: DataTypes.ENUM,
values: ['LeagueofLegends', 'Valorant', 'CS:GO'],
},
importHash: {
type: DataTypes.STRING(255),
allowNull: true,
unique: true,
},
},
{
timestamps: true,
paranoid: true,
freezeTableName: true,
},
);
tactics.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.tactics.belongsTo(db.teams, {
as: 'team',
foreignKey: {
name: 'teamId',
},
constraints: false,
});
db.tactics.belongsTo(db.equipos, {
as: 'equipos',
foreignKey: {
name: 'equiposId',
},
constraints: false,
});
db.tactics.belongsTo(db.users, {
as: 'createdBy',
});
db.tactics.belongsTo(db.users, {
as: 'updatedBy',
});
};
return tactics;
};