82 lines
1.7 KiB
JavaScript
82 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 threat_feeds = sequelize.define(
|
|
'threat_feeds',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
title: {
|
|
type: DataTypes.TEXT,
|
|
},
|
|
|
|
description: {
|
|
type: DataTypes.TEXT,
|
|
},
|
|
|
|
date_received: {
|
|
type: DataTypes.DATE,
|
|
},
|
|
|
|
severity: {
|
|
type: DataTypes.ENUM,
|
|
|
|
values: ['Low', 'Medium', 'High', 'Critical'],
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
threat_feeds.associate = (db) => {
|
|
db.threat_feeds.belongsToMany(db.users, {
|
|
as: 'annotators',
|
|
foreignKey: {
|
|
name: 'threat_feeds_annotatorsId',
|
|
},
|
|
constraints: false,
|
|
through: 'threat_feedsAnnotatorsUsers',
|
|
});
|
|
|
|
db.threat_feeds.belongsToMany(db.users, {
|
|
as: 'annotators_filter',
|
|
foreignKey: {
|
|
name: 'threat_feeds_annotatorsId',
|
|
},
|
|
constraints: false,
|
|
through: 'threat_feedsAnnotatorsUsers',
|
|
});
|
|
|
|
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
|
|
|
//end loop
|
|
|
|
db.threat_feeds.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.threat_feeds.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
return threat_feeds;
|
|
};
|