122 lines
1.8 KiB
JavaScript
122 lines
1.8 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 headline_batches = sequelize.define(
|
|
'headline_batches',
|
|
{
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
|
|
headlines_json: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
vocab_json: {
|
|
type: DataTypes.TEXT,
|
|
|
|
|
|
|
|
},
|
|
|
|
sentiment_score: {
|
|
type: DataTypes.DECIMAL,
|
|
|
|
|
|
|
|
},
|
|
|
|
created_at_ts: {
|
|
type: DataTypes.DATE,
|
|
|
|
|
|
|
|
},
|
|
|
|
importHash: {
|
|
type: DataTypes.STRING(255),
|
|
allowNull: true,
|
|
unique: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
paranoid: true,
|
|
freezeTableName: true,
|
|
},
|
|
);
|
|
|
|
headline_batches.associate = (db) => {
|
|
|
|
|
|
/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.headline_batches.hasMany(db.forecast_runs, {
|
|
as: 'forecast_runs_headline_batch',
|
|
foreignKey: {
|
|
name: 'headline_batchId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//end loop
|
|
|
|
|
|
|
|
db.headline_batches.belongsTo(db.symbols, {
|
|
as: 'symbol',
|
|
foreignKey: {
|
|
name: 'symbolId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
db.headline_batches.belongsTo(db.users, {
|
|
as: 'author',
|
|
foreignKey: {
|
|
name: 'authorId',
|
|
},
|
|
constraints: false,
|
|
});
|
|
|
|
|
|
|
|
|
|
db.headline_batches.belongsTo(db.users, {
|
|
as: 'createdBy',
|
|
});
|
|
|
|
db.headline_batches.belongsTo(db.users, {
|
|
as: 'updatedBy',
|
|
});
|
|
};
|
|
|
|
|
|
|
|
return headline_batches;
|
|
};
|
|
|
|
|