I use sequelize-cli to auto generate code for model Student:
module.exports = (sequelize, DataTypes) => {
var _stu = sequelize.define('stu', {
name: DataTypes.STRING,
password: DataTypes.STRING,
gender: DataTypes.INTEGER,
}, {
classMethods: {
associate: function(models) {
// associations can be defined here
}
}
});
return _stu
};
My question are
- How to get model named
stu
? As thesequelize
is defined in function signature.
When sequelize model:generate
,sequelize read config in config.json,where dbname,passowrd are specified.
- How the
sequelize
in the function signature knows database connection config,say,name,password,etc as I don't specify in this js file.