const testName = await dataBase.findAll({
where: {
id: {
[Op.between]: [20, 25]
}
}
})
比如以上例子,
假设
//testName为
[
food{
dataValues:{
id:23,
title:test3
},
}
]
我将op到的数据放在了testName里,如果直接利用
console.log(testName.id)
//将会返回undefined
正确操作应该先将数据进行for....of...遍历
for(const list of testName){
console.log(list.id)
}
经测试,如果只有一个数据,返回的内容是一样的。但要应用其子内容属性,则必须先遍历。
以上纯属个人总结。。不知正确与否。