text: // See http://docs.sequelizejs.com/en/latest/docs/models-definition/
  // for more of what you can do here.
  const Sequelize = require('sequelize');
  const DataTypes = Sequelize.DataTypes;
  
  module.exports = function (app) {
    const sequelizeClient = app.get('sequelizeClient');
    const category = sequelizeClient.define('category', {
      name: {
        type: DataTypes.STRING,
        allowNull: false,
        unique: true,
      },
      names: {
        type: DataTypes.JSONB,
      },
      active: {
        type: DataTypes.BOOLEAN,
        defaultValue: true,
      },
      icon: {
        type: DataTypes.STRING,
        allowNull: true,
      },
      parentId: {
        type: DataTypes.INTEGER,
        allowNull: true,
        references: {
          model: 'category',
          key: 'id',
        },
      },
    }, {
      hooks: {
        beforeCount(options) {
          options.raw = true;
        }
      }
    });
  
    // eslint-disable-next-line no-unused-vars
    category.associate = function (models) {
      category.belongsTo(category, { as: 'parent' });
    };
  
    return category;
  };
  