在我的Sequelize模型中,我有这个模型
module.exports = function(sequelize, Sequelize) {
return sequelize.define('TradingPlan', {
id: {
primaryKey: true,
autoIncrement: true,
type: Sequelize.INTEGER
},
name:Sequelize.STRING,
symbol: Sequelize.STRING(10),
symbol_pair: Sequelize.STRING(10),
entry_type: Sequelize.STRING(10),
conditional_long_entry_point: Sequelize.DECIMAL(18,8),
conditional_short_entry_point: Sequelize.DECIMAL(18,8),
entry_price: Sequelize.DECIMAL(18,8),
entry_order_type: Sequelize.STRING(10),
pyramid_entry: Sequelize.BOOLEAN,
exchange: Sequelize.STRING(30),
notes: Sequelize.STRING, <----------This is the problem one
当我检索notes
表数据时,它输出如下
[object Object]
然后,当我试图编辑这个表中的一个帖子时,它不会接受它,因为它是一个对象。即使它是作为字符串输入的。我通常输入This is a good note!
我收到的错误是
name: 'SequelizeValidationError',
errors:
[ ValidationErrorItem {
message: 'notes cannot be an array or an object',
type: 'string violation',
path: 'notes',
value: [Object],
origin: 'CORE',
instance: [Object],
validatorKey: 'not_a_string',
at Promise._settlePromiseFromHandler (C:\node\trade-
mentor\node_modules\bluebird\js\release\promise.js:517:31
)
我没在谷歌上搜索过这个,还有人看过这个吗?
发布于 2019-05-30 01:36:56
我在Mysql中的数据类型是错误的,我把它当成了Blob
,我在Sequelize中也把数据类型改成了Text
。
https://stackoverflow.com/questions/56363596
复制相似问题