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 match_spawns = sequelize.define( 'match_spawns', { id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true, }, spawn_name: { type: DataTypes.TEXT, }, pos_x: { type: DataTypes.DECIMAL, }, pos_y: { type: DataTypes.DECIMAL, }, pos_z: { type: DataTypes.DECIMAL, }, rot_yaw: { type: DataTypes.DECIMAL, }, rot_pitch: { type: DataTypes.DECIMAL, }, team: { type: DataTypes.ENUM, values: [ "alpha", "bravo", "neutral" ], }, importHash: { type: DataTypes.STRING(255), allowNull: true, unique: true, }, }, { timestamps: true, paranoid: true, freezeTableName: true, }, ); match_spawns.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.match_spawns.belongsTo(db.matches, { as: 'match', foreignKey: { name: 'matchId', }, constraints: false, }); db.match_spawns.belongsTo(db.maps, { as: 'map', foreignKey: { name: 'mapId', }, constraints: false, }); db.match_spawns.belongsTo(db.users, { as: 'createdBy', }); db.match_spawns.belongsTo(db.users, { as: 'updatedBy', }); }; return match_spawns; };