node.js - Sequelize findByPk 的结果

标签 node.js sequelize.js

我想找到一个带有 id 的 itme 是: 1 const student = await this.db.Student.findByPk(1)当我得到结果然后安慰它(console.log(student))

student {
  dataValues: { id: 1, name: 'Darush', family: 'Hamidi' },
  _previousDataValues: { id: 1, name: 'Darush', family: 'Hamidi' },
  _changed: Set(0) {},
  _options: {
    isNewRecord: false,
    _schema: null,
    _schemaDelimiter: '',
    raw: true,
    attributes: [ 'id', 'name', 'family' ]
  },
  isNewRecord: false
}
然后将学生发送到浏览器结果将是( res.send(student) )?
{
  "id": 1,
  "name": "Darush",
  "family": "Hamidi"
}
为什么我们有区别?

最佳答案

我将 rwa 设置为 true :它完美地工作

const student = await this.db.Student.findByPk(1,{ raw: true })

关于node.js - Sequelize findByPk 的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64610001/

相关文章:

node.js - bash,nohup sh 文件启动 Node , Node 在注销时挂起?

node.js - 通过中间模型 Sequelize 急切加载

sequelize.js - 三通关系

node.js - Sequelize : can attribute have value from relation attribute data?

node.js - sequelize .create is not a function 错误

node.js - 如何从 s3 存储桶解析 CSV 以在 JavaScript AWS Lambda 函数中使用

javascript - Puppeteer 错误 错误 : waiting on selector times out

node.js - 强制重新安装 Node 模块

javascript - NodeJS REPL 变量赋值——需要帮助找出问题所在

javascript - 使用 lodash、下划线或数组函数的多级/多级组