%PDF- %PDF-
 Mini Shell
 Mini Shell  
 | Direktori : /home/opti/workflow/src/models/ | 
| Current File : /home/opti/workflow/src/models/organisationstructure.js | 
'use strict';
module.exports = (sequelize, DataTypes) => {
  const OrganisationStructure = sequelize.define('OrganisationStructure', {
    orgId: DataTypes.INTEGER,
    structureId: DataTypes.INTEGER,
    parentId: DataTypes.INTEGER,
    order: DataTypes.INTEGER,
    createdAt: DataTypes.DATE,
    updatedAt: DataTypes.DATE
  }, {});
  
  OrganisationStructure.associate = function(models) {
    // associations can be defined here
    OrganisationStructure.belongsTo(models.Structure, { foreignKey: 'structureId', as: 'structure'});
    OrganisationStructure.hasMany(models.CompanyStructure, { foreignKey: 'orgStructureId', targetKey:'id', as:'children'});
    OrganisationStructure.hasOne(models.OrganisationStructure, { foreignKey: 'parentId', as: 'parent'})
  };
  return OrganisationStructure;
};