90 lines
1.8 KiB
JavaScript
90 lines
1.8 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 player_season_stats = sequelize.define(
|
|
'player_season_stats',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
totalpoints: {
|
|
type: DataTypes.INTEGER,
|
|
},
|
|
|
|
gamesplayed: {
|
|
type: DataTypes.INTEGER,
|
|
},
|
|
|
|
eightballruns: {
|
|
type: DataTypes.INTEGER,
|
|
},
|
|
|
|
eightballbreaks: {
|
|
type: DataTypes.INTEGER,
|
|
},
|
|
|
|
nineballruns: {
|
|
type: DataTypes.INTEGER,
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
player_season_stats.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.player_season_stats.belongsTo(db.leagues, {
|
|
as: 'leagues',
|
|
foreignKey: {
|
|
name: 'leaguesId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.player_season_stats.belongsTo(db.players, {
|
|
as: 'player',
|
|
foreignKey: {
|
|
name: 'playerId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.player_season_stats.belongsTo(db.seasons, {
|
|
as: 'season',
|
|
foreignKey: {
|
|
name: 'seasonId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.player_season_stats.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.player_season_stats.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
return player_season_stats;
|
|
};
|