node.js - Sequelize String 作为 [Object object] 输出

标签 node.js sequelize.js

在我的 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
)

我没有任何运气谷歌搜索这个,有没有其他人看到这个?

最佳答案

我在 Mysql 中的数据类型错误,我将它作为 Blob ,在阅读了更多关于它的信息后,我还将 Sequelize 中的数据类型更改为 Text

关于node.js - Sequelize String 作为 [Object object] 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56363596/

相关文章:

angularjs - 使用 Angular 和 Express JS 下载所有文件格式

javascript - 检测 HTML 输入表的更改输入值

arrays - Sequelize - 在数组列中查找项目

node.js - Sequelize 查询给出 TypeError : undefined is not a function

javascript - 当我使用 findById(req.params.id) 时,我的 Sequelize 查询总是进行错误的查询

javascript - 在 TypeORM 中,如何根据该实体的其他字段在实体上预先计算字段?

node.js - SequelizeEagerLoadingError 当模型之间的关系已经被定义时

node.js - 如何让webpack使用父目录中的共享 Node 模块

arrays - 使用 MarkLogic Patch Builder 在 JSON 数组的末尾插入一个新的数组项

javascript - 如何从 API 中删除 JWT 身份验证?