%PDF- %PDF-
Direktori : /home/opti/workflow/src/models/ |
Current File : /home/opti/workflow/src/models/request.js |
'use strict'; module.exports = (sequelize, DataTypes) => { const Request = sequelize.define('Request', { uuid: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4 }, serviceType: DataTypes.STRING, amount: DataTypes.REAL, title: DataTypes.STRING, description: DataTypes.STRING, justification: DataTypes.STRING, nextOfficer: DataTypes.INTEGER, owner: DataTypes.INTEGER, workflowId: DataTypes.INTEGER, targetedStructure: DataTypes.INTEGER, previousOfficer: DataTypes.INTEGER, status: DataTypes.STRING, supervisorComment: DataTypes.STRING, }, {}); Request.associate = function(models) { // associations can be defined here Request.belongsTo(models.User, {foreignKey: 'owner', targetKey: 'id', as: 'requestOwner'}); Request.belongsTo(models.User, {foreignKey: 'previousOfficer', targetKey: 'id', as: 'requestPrevOfficer'}); Request.belongsTo(models.User, {foreignKey: 'nextOfficer', targetKey: 'id', as: 'requestNextOfficer'}); Request.belongsTo(models.CompanyStructure, {foreignKey: 'targetedStructure', targetKey: 'id', as: 'structure'}); Request.belongsTo(models.Workflow, {foreignKey: 'workflowId', targetKey: 'id', as: 'workflow'}); // Request.hasMany(RequestHistory, { foreignKey: 'requestId', as:'histories'}); Request.hasMany(models.RequestHistory, {foreignKey: 'requestId', as: 'histories'}) }; return Request; };