39242-vm/backend/src/db/models/hint_events.js
2026-03-19 12:24:37 +00:00

133 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 hint_events = sequelize.define(
'hint_events',
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
hint_type: {
type: DataTypes.ENUM,
values: [
"next_cell",
"direction_arrow",
"turn_constraint",
"segment_reveal",
"validity_check",
"explain_rule"
],
},
request_context: {
type: DataTypes.TEXT,
},
response_payload: {
type: DataTypes.TEXT,
},
step_index: {
type: DataTypes.INTEGER,
},
requested_at: {
type: DataTypes.DATE,
},
importHash: {
type: DataTypes.STRING(255),
allowNull: true,
unique: true,
},
},
{
timestamps: true,
paranoid: true,
freezeTableName: true,
},
);
hint_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.hint_events.belongsTo(db.play_sessions, {
as: 'play_session',
foreignKey: {
name: 'play_sessionId',
},
constraints: false,
});
db.hint_events.belongsTo(db.users, {
as: 'createdBy',
});
db.hint_events.belongsTo(db.users, {
as: 'updatedBy',
});
};
return hint_events;
};