Al momento de crear mi usuario tengo este problema:
{"name":"SequelizeDatabaseError","parent":{"errno":1,"code":"SQLITE_ERROR","sql":"INSERT INTO Users
(id
,email
,password_hash
,createdAt
,updatedAt
) VALUES (NULL,$1,$2,$3,$4);"},"original":{"errno":1,"code":"SQLITE_ERROR","sql":"INSERT INTO Users
(id
,email
,password_hash
,createdAt
,updatedAt
) VALUES (NULL,$1,$2,$3,$4);"},"sql":"INSERT INTO Users
(id
,email
,password_hash
,createdAt
,updatedAt
) VALUES (NULL,$1,$2,$3,$4);","parameters":{}}
Básicamente me sale error, pero no encuentro el porque, creo que el error esta en el modelo, lo muestro:
'use strict'; const bcrypt=require("bcrypt"); module.exports = (sequelize, DataTypes) => { const User= sequelize.define('User',{ email:{ type: DataTypes.STRING, unique: true, allowNull:false }, password_hash: DataTypes.STRING, password:DataTypes.VIRTUAL },{}); User.beforeCreate((user,options)=>{ return new Promise((res,rej)=>{ if(user.password){ bcrypt.hash(user.password,10,function(error,hash){ user.password_hash=hash; res(); }) } }); }); return User; };