sequelize-import-models
v1.0.0
Published
this is sequelize models helper
Downloads
1
Readme
sequelize-import-models
this is sequelize models helper
example
const models = require('sequelize-import-models')
models.connect({
database: 'blog',
username: 'root',
password: '',
host: 'localhost',
dialect: 'mysql',
path: 'models/*.js' // glob path
})
console.log(models) // all models and sequelize object
associations
module.exports = function (sequelize, DataTypes) {
return sequelize.define('User', {
username: DataTypes.STRING
}, {
classMethods: {
associate: function(models) {
User.hasMany(models.Task)
}
}
})
}
http://docs.sequelizejs.com/en/1.7.0/docs/associations/ http://docs.sequelizejs.com/en/1.7.0/articles/express/#modelsuserjs