66 lines
1.3 KiB
JavaScript
66 lines
1.3 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 game_statistics = sequelize.define(
|
|
'game_statistics',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
active_players: {
|
|
type: DataTypes.INTEGER,
|
|
},
|
|
|
|
total_plays: {
|
|
type: DataTypes.INTEGER,
|
|
},
|
|
|
|
last_played: {
|
|
type: DataTypes.DATE,
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
game_statistics.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.game_statistics.belongsTo(db.games, {
|
|
as: 'game',
|
|
foreignKey: {
|
|
name: 'gameId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.game_statistics.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.game_statistics.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
return game_statistics;
|
|
};
|