Defined my User.js model as under but getting below exception
Error
PS C:\Users\meghshyam\Documents\express_node_mysql_handlebars> node server.js C:\Users\meghshyam\Documents\express_node_mysql_handlebars\node_modules\sequelize\lib\sequelize.js:691 this.importCache[path] = defineCall(this, DataTypes); ^
TypeError: defineCall is not a function at Sequelize.import (C:\Users\meghshyam\Documents\express_node_mysql_handlebars\node_modules\sequelize\lib\sequelize.js:691:30) at C:\Users\meghshyam\Documents\express_node_mysql_handlebars\models\index.js:23:36 at Array.forEach (native) at Object. (C:\Users\meghshyam\Documents\express_node_mysql_handlebars\models\index.js:22:4) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object. (C:\Users\meghshyam\Documents\express_node_mysql_handlebars\server.js:16:10) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Function.Module.runMain (module.js:441:10)
"use strict";
module.exports = function(sequelize, DataTypes) {
var User = sequelize.define("User",
{
//timestamps: true,
// id:DataTypes.INTEGER,
username:{
type:DataTypes.STRING,
validate:{
isEmail:true
}
},
password: {
type: DataTypes.STRING,
validate:{
len:[6,12],
notNull:true,
notEmpty:true
}
},
role:{
type: DataTypes.INTEGER,
validate:{
notNull:true,
notEmpty:true,
isNumeric:true
},
}
},
{
classMethods: {
associate: function(models) {
// Associating Author with Posts
// When an Author is deleted, also delete any associated Posts
// User.belongsTo(models.Student, {
// onDelete: "cascade"
// });
//user has one teacher record
// User.belongsTo(models.Teacher, {
// onDelete: "cascade"
});
}
}
}
);
return User;
};