// See http://docs.sequelizejs.com/en/latest/docs/models-definition/
// for more of what you can do here.
const Sequelize = require('sequelize');

module.exports = function(app) {
  const sequelizeClient = app.get('sequelizeClient');
  const unitsTypes = sequelizeClient.define(
    'unitsTypes',
    {
      name: {
        type: Sequelize.STRING,
        allowNull: false,
      },
    },
    {
      underscoredAll: true,
      classMethods: {
        associate(models) {
          // eslint-disable-line no-unused-vars
          // Define associations here
          // See http://docs.sequelizejs.com/en/latest/docs/associations/
          this.hasMany(models.units, { as: 'units'});
        },
      },
    }
  );

  return unitsTypes;
};
