const Sequelize = require('sequelize');
const bcrypt = require('bcrypt');
const uuidV4 = require('uuid/v4');


module.exports = (sequelize) => {
  return sequelize.define('user', {
    id: {
      type: Sequelize.STRING,
      primaryKey: true
    },
    email: {
      type: Sequelize.STRING(400),
      allowNull: false,
      validate: {
        isEmail: true,
      }
    },
    password: {
      type: Sequelize.STRING(100),
    }
  }, {
    freezeTableName: true, // Model tableName will be the same as the model name
    comment: 'user base information',
    indexes: [{
      unique: true,
      fields: ['email'],
    }],
    classMethods: {
      add: async function add(userInfo) {
        const salt = await bcrypt.genSalt(10);
        userInfo.password = await bcrypt.hash(userInfo.password, salt);
        userInfo.id = uuidV4();
        const user = this.build(userInfo);
        return await user.save();
      },
      findByEmail: async function findByEmail(email) {
        return await this.find({ where: { email }});
      },
      findByID: async function findByID(id) {
        return await this.find({ where: { id }});
      }
    },
  });
}

@@ -78,17 +78,17 @@
 st uuidV
-4
+1
  = requi
@@ -97,17 +97,17 @@
 ('uuid/v
-4
+1
 ');%0A%0A%0Amo
@@ -832,17 +832,17 @@
  = uuidV
-4
+1
 ();%0A    

Change uuuidv4 to uuidv1