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 face_matches = sequelize.define( 'face_matches', { id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true, }, match_score: { type: DataTypes.DECIMAL, }, confidence_badge: { type: DataTypes.ENUM, values: [ "low", "medium", "high", "very_high" ], }, matched_at: { type: DataTypes.DATE, }, importHash: { type: DataTypes.STRING(255), allowNull: true, unique: true, }, }, { timestamps: true, paranoid: true, freezeTableName: true, }, ); face_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.face_matches.belongsTo(db.selfie_references, { as: 'selfie_reference', foreignKey: { name: 'selfie_referenceId', }, constraints: false, }); db.face_matches.belongsTo(db.face_detections, { as: 'face_detection', foreignKey: { name: 'face_detectionId', }, constraints: false, }); db.face_matches.belongsTo(db.organizations, { as: 'organizations', foreignKey: { name: 'organizationsId', }, constraints: false, }); db.face_matches.belongsTo(db.users, { as: 'createdBy', }); db.face_matches.belongsTo(db.users, { as: 'updatedBy', }); }; return face_matches; };