How to use an include with attributes with sequelize?

后端 未结 2 1780
执笔经年
执笔经年 2020-12-05 12:33

Any idea how to use an include with attributes (when you need to include only specific fields of the included table) with sequelize?

Currently I have this (but it do

2条回答
  •  情话喂你
    2020-12-05 13:23

    We can do something like that for exclude or include specific attribute with sequelize in Node.js.

    Payment.findAll({
        where: {
            DairyId: req.query.dairyid
        },
        attributes: {
            exclude: ['createdAt', 'updatedAt']
        },
        include: {
            model: Customer,
            attributes:['customerName', 'phoneNumber']
        }
    })
    

提交回复
热议问题