38890-vm/backend/src/db/models/python_service_models.js
2026-02-28 21:53:45 +00:00

129 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 python_service_models = sequelize.define(
'python_service_models',
{
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true,
},
name: {
type: DataTypes.TEXT,
},
model_type: {
type: DataTypes.ENUM,
values: [
"sentiment_classifier"
],
},
artifact_uri: {
type: DataTypes.TEXT,
},
metrics_json: {
type: DataTypes.TEXT,
},
is_active: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
},
created_at_ts: {
type: DataTypes.DATE,
},
importHash: {
type: DataTypes.STRING(255),
allowNull: true,
unique: true,
},
},
{
timestamps: true,
paranoid: true,
freezeTableName: true,
},
);
python_service_models.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.python_service_models.belongsTo(db.users, {
as: 'author',
foreignKey: {
name: 'authorId',
},
constraints: false,
});
db.python_service_models.belongsTo(db.users, {
as: 'createdBy',
});
db.python_service_models.belongsTo(db.users, {
as: 'updatedBy',
});
};
return python_service_models;
};