136 lines
1.6 KiB
JavaScript
136 lines
1.6 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 hit_events = sequelize.define(
|
|
'hit_events',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
time_offset_ms: {
|
|
type: DataTypes.DECIMAL,
|
|
|
|
|
|
|
|
},
|
|
|
|
judgement: {
|
|
type: DataTypes.ENUM,
|
|
|
|
|
|
|
|
values: [
|
|
|
|
"perfect",
|
|
|
|
|
|
"great",
|
|
|
|
|
|
"good",
|
|
|
|
|
|
"bad",
|
|
|
|
|
|
"miss"
|
|
|
|
],
|
|
|
|
},
|
|
|
|
combo_at_hit: {
|
|
type: DataTypes.INTEGER,
|
|
|
|
|
|
|
|
},
|
|
|
|
score_delta: {
|
|
type: DataTypes.DECIMAL,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
hit_events.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.hit_events.belongsTo(db.game_sessions, {
|
|
as: 'session',
|
|
foreignKey: {
|
|
name: 'sessionId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.hit_events.belongsTo(db.routine_moves, {
|
|
as: 'move',
|
|
foreignKey: {
|
|
name: 'moveId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
|
|
db.hit_events.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.hit_events.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return hit_events;
|
|
};
|
|
|
|
|