%PDF- %PDF-
Direktori : /home/opti/workflow/src/models/ |
Current File : /home/opti/workflow/src/models/companystructure.js |
'use strict'; module.exports = (sequelize, DataTypes) => { const CompanyStructure = sequelize.define('CompanyStructure', { orgId: DataTypes.INTEGER, orgStructureId: DataTypes.INTEGER, parentStructureId: DataTypes.INTEGER, name: DataTypes.STRING, email: DataTypes.STRING, headId: DataTypes.INTEGER, assistantId: DataTypes.INTEGER, createdBy: DataTypes.INTEGER, UpdatedBy: DataTypes.INTEGER, deletedAt: DataTypes.DATE, deletedBy: DataTypes.INTEGER }, {}); CompanyStructure.associate = function(models) { // associations can be defined here CompanyStructure.belongsTo(models.Organization, {foreignKey: 'orgId', targetKey: 'id', as: 'organisation'}); // CompanyStructure.belongsTo(models.Structure, {foreignKey: 'parentStructureId', targetKey: 'id', as: 'parentStructure'}); CompanyStructure.belongsTo(models.OrganisationStructure, {foreignKey: 'orgStructureId', targetKey: 'id', as: 'orgStructure'}); CompanyStructure.belongsTo(models.User, {foreignKey: 'headId', targetKey: 'id', as: 'head'}); CompanyStructure.belongsTo(models.User, {foreignKey: 'assistantId', targetKey: 'id', as: 'assistant'}); CompanyStructure.hasMany(models.User, {foreignKey: 'companyStructureId', sourceKey: 'id', as: 'employees'}) CompanyStructure.hasMany(models.Workflow, { foreignKey: 'companyStructureId', as:'workflows'}); //for bovas workflow CompanyStructure.hasMany(models.Flow, { foreignKey: 'companyStructureId', as:'flows'}); }; return CompanyStructure; }