%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/opti/workflow/src/models/
Upload File :
Create Path :
Current File : /home/opti/workflow/src/models/branch.js

'use strict';

module.exports = (sequelize, DataTypes) => {
  const Branches = sequelize.define('Branch', {
    name: DataTypes.STRING,
    description: DataTypes.STRING,
    email: DataTypes.STRING,
    regionId: DataTypes.INTEGER,
    orgId: DataTypes.INTEGER,
    headId: DataTypes.INTEGER,
    assistantId: DataTypes.INTEGER,
    addedById: DataTypes.INTEGER,
    updatedById: DataTypes.INTEGER,
    deletedAt: DataTypes.DATE,
    deletedById: DataTypes.INTEGER
  }, {});

  // Branches.belongsTo(User, {foreignKey: 'headId', targetKey: 'id', as: 'head'});
  // Branches.belongsTo(User, {foreignKey: 'assistantId', targetKey: 'id', as: 'assistant'});

  Branches.associate = function(models) {
    // associations can be defined here
    Branches.belongsTo(models.Region, { foreignKey: 'regionId', as: 'region' })
    Branches.belongsTo(models.User, { foreignKey: 'headId', as: 'head' })
    Branches.belongsTo(models.User, { foreignKey: 'assistantId', as: 'assistant' })
    
  };
  return Branches;
};

Zerion Mini Shell 1.0