我在尝试使用 nodeJs 配置 postrgres 时遇到问题,我按照本教程进行操作,但我收到一个错误,该错误没有指定任何关于错误的内容:
这是堆栈跟踪
Unhandled rejection Error: Include unexpected. Element has to be either a Model, an Association or an object.
at C:\Users\FilipeCosta\desktop\FloraApp\server\node_modules\sequelize\lib\model.js:1976:15
at Array.map (native)
at conformOptions (C:\Users\FilipeCosta\desktop\FloraApp\server\node_modules\sequelize\lib\model.js:1941:39)
at Model.<anonymous> (C:\Users\FilipeCosta\desktop\FloraApp\server\node_modules\sequelize\lib\model.js:700:7)
at Model.tryCatcher (C:\Users\FilipeCosta\desktop\FloraApp\server\node_modules\sequelize\node_modules\bluebird\js\main\util.js:26:23)
at Promise._settlePromiseFromHandler (C:\Users\FilipeCosta\desktop\FloraApp\server\node_modules\sequelize\node_modules\bluebird\js\main\promise.js:503:31)
at Promise._settlePromiseAt (C:\Users\FilipeCosta\desktop\FloraApp\server\node_modules\sequelize\node_modules\bluebird\js\main\promise.js:577:18)
at Promise._settlePromiseAtPostResolution (C:\Users\FilipeCosta\desktop\FloraApp\server\node_modules\sequelize\node_modules\bluebird\js\main\promise.js:244:10)
at Async._drainQueue (C:\Users\FilipeCosta\desktop\FloraApp\server\node_modules\sequelize\node_modules\bluebird\js\main\async.js:128:12)
at Async._drainQueues (C:\Users\FilipeCosta\desktop\FloraApp\server\node_modules\sequelize\node_modules\bluebird\js\main\async.js:133:10)
at Immediate.Async.drainQueues (C:\Users\FilipeCosta\desktop\FloraApp\server\node_modules\sequelize\node_modules\bluebird\js\main\async.js:15:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
我的模型:
var express = require('express');
var models = require('../models');
var router = express.Router();
/* GET users listing. */
router.get('/', function (req, res, next) {
var User = models.User;
User.findById(1).then(function (user) {
console.log(user);
})
});
module.exports = router;
我的路由器:
“使用严格”;
module.exports = function(sequelize, DataTypes) {
var User = sequelize.define("User", {
username: DataTypes.STRING,
id: DataTypes.INTEGER,
email: DataTypes.STRING
});
return User;
};