Skip to content
Advertisement

Select and join with sequelize

How to make this code with the sequelize?

I used include, but it brings all the user data but I only need the name

my code:

Advertisement

Answer

If you just want to reduce User model attributes then just indicate needed attributes in the attributes option:

If you want to add a user’s name as a string prop at the same level as all Comments fields simply indicate it in the attributes option of Comments model with a desired alias:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement