0

I have this Sequelize Model named Recipe where I need to make a join from Model Diet, but I get an array of objects with only the property I want, but I would like to get it as a string, not an object.

const dbDataTest = await Recipe.findAll({

    include: [
      {
        model: Diet,
        attributes: {
            exclude: ['createdAt', 'updatedAt', 'id']
        },
        through: {attributes: []}
      },
    ],
});

That's why I'm excluding 3 other attributes so I can get only this output:

{
Recipe name: 'Name',
diets: ['diet one', 'diet two']
}

instead, I'm Getting:

{
Recipe name: 'Name',
diets:[
        {name: 'diet one'},
        {name: 'diet two'}
      ]
}
2
  • I think this may answer your question stackoverflow.com/a/65298661/10213537 Commented Jul 12, 2021 at 13:03
  • @Ameer Thanks, I already implemented a map but I wanted to know if there was a way to do it with sequelize Commented Jul 12, 2021 at 21:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.