31899/backend/src/db/models/indicators.js
2025-06-01 01:47:48 +00:00

64 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 indicators = sequelize.define(
'indicators',
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
indicator: {
type: DataTypes.TEXT,
},
threat_level: {
type: DataTypes.ENUM,
values: ['Low', 'Medium', 'High'],
},
importHash: {
type: DataTypes.STRING(255),
allowNull: true,
unique: true,
},
},
{
timestamps: true,
paranoid: true,
freezeTableName: true,
},
);
indicators.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.indicators.belongsTo(db.threat_hunters, {
as: 'analyzed_by',
foreignKey: {
name: 'analyzed_byId',
},
constraints: false,
});
db.indicators.belongsTo(db.users, {
as: 'createdBy',
});
db.indicators.belongsTo(db.users, {
as: 'updatedBy',
});
};
return indicators;
};