我正在使用express.js和sequelize开发小型应用程序。 现在我有一个问题。我去用this tutorial和stucked。通过githubExpress.js和Sequelize:未定义模型
'use strict';
module.exports = function(sequelize, DataTypes) {
var Article = sequelize.define('Article', {
title: DataTypes.STRING,
content: DataTypes.TEXT
}, {
classMethods: {
associate: function(models) {
// associations can be defined here
}
}
});
return Article;
};
我主项目,你可以看到有任何代码:
我越来越
TypeError: Cannot read property 'findAll' of undefined
为
router.get('/news', function (req, res, next) {
models.Article.findAll().then(function(article) {
res.json(article);
});
});
我的模型。
感谢您的帮助。
UPD:添加console.log(models)路由/新闻。
你可以添加'的console.log(型号)''进/ news'路由器,并显示它给我吗? –
我已经更新了您所要求的console.log文章。 – skad0