Sequelize include - Don't include (remove) pivot data

喜夏-厌秋 提交于 2019-12-23 02:39:07

问题


I'm using the Sequelize package for node. I have a typical include on man to many relationship.

Item.findAll({
    include: {model: Blah: as 'blahs'}
});

All works well but it returns the set with the pivot data on each sub item. I don't need it. Is there any way to disable it or to specify the pivot fields needed?


回答1:


Found my answer:

{model: Model, as: 'model', through: {attributes: []}}



回答2:


It is not very clear what you are looking for but can you try adding raw:true

Item.findAll({
    include: {model: Blah, raw: true}
});

can you post the result you got vs result you want



来源:https://stackoverflow.com/questions/33798994/sequelize-include-dont-include-remove-pivot-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!