我想选择要从表中检索的列,并使用属性进行续集。
但它没有按预期工作:
messengerModel.findAll({
attributes: ['message_title']
})
此代码返回表中的所有列:
SELECT `id`, `room_id`, `sender`, `message_id`, `message_source`, `status`, `message_content`, `message_uid`, `recipient`, `conversation`, `mail_date`, `person_id`, `message_title` FROM `messenger`
有人遇到这个问题吗?
我正在使用sequelize 6.20.1
感谢您的帮助!
我建议确保表名正确。另外,我在这里看到了一些选项(第一个或第二个):
选项1:下面给出的模型名称与sql查询中提到的模型名称不同。
选项2:我可以说检查你的messengerModel的定义以确保message_title属性被正确定义。模型定义应包含您要访问的所有列。
messengerModel.findAll({
attributes: ['message_title']
})