sequelize include only 1

sequelize include only

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

Here is what the above code is Doing:
1. We are querying the Payment table for all the payments that have a DairyId equal to the dairyid that was passed in the query string.
2. We are excluding the createdAt and updatedAt attributes from the result.
3. We are including the Customer model in the result.
4. We are including only the customerName and phoneNumber attributes of the Customer model in the result.

Similar Posts