我想找到一个带有 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/