我想知道这个错误的性质?任何想法调试都将非常感谢!
Unhandled rejection SequelizeBaseError: null
at /Users/master/node_modules/sequelize/lib/instance-validator.js:74:14
at tryCatcher (/Users/master/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (.
我想我正在传递所有必填字段,如下所示:
app.post("/api/posts", function(req, res) {
console.log(req.body);
db.Post.create({
image: req.body.image,
caption: req.body.caption,
tags: req.body.tags
}).then(function(dbPost) {
res.redirect('/');
console.log("posted!")
});
});
检查allowNotNull,数据类型ok,等等
这是我的模特:
var Post = sequelize.define("Post", {
caption: {
type: DataTypes.TEXT,
allowNull: false,
validate: {
len: [1]
}
},
likes: {
type: DataTypes.INTEGER,
defaultValue: 0
},
image: {
type: DataTypes.STRING,
allowNull: false
},
tags: {
type: DataTypes.STRING
}
}
答案 0 :(得分:1)
这是典型的sed 's/\(.*\)\([{}]\)\(.*\)/\1\n\2\n\3/' file.c |
grep -v '^\s*$' > file.preprocessed.c
,因为您Unhandled Promise Rejection Error
之后没有.catch
:
.then
您的代码中存在错误,但由于Promise的异步性质以及您没有发现错误,您实际上并未知道它是什么。