2026-01-30 19:05:11 +00:00

137 lines
1.7 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 matches = sequelize.define(
'matches',
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
compatibility_score: {
type: DataTypes.DECIMAL,
},
factors: {
type: DataTypes.TEXT,
},
last_calculated: {
type: DataTypes.DATE,
},
status: {
type: DataTypes.ENUM,
values: [
"pending",
"matched",
"rejected",
"archived"
],
},
name: {
type: DataTypes.TEXT,
},
importHash: {
type: DataTypes.STRING(255),
allowNull: true,
unique: true,
},
},
{
timestamps: true,
paranoid: true,
freezeTableName: true,
},
);
matches.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.matches.belongsTo(db.users, {
as: 'user_a',
foreignKey: {
name: 'user_aId',
},
constraints: false,
});
db.matches.belongsTo(db.users, {
as: 'user_b',
foreignKey: {
name: 'user_bId',
},
constraints: false,
});
db.matches.belongsTo(db.users, {
as: 'createdBy',
});
db.matches.belongsTo(db.users, {
as: 'updatedBy',
});
};
return matches;
};