Skip to content
Advertisement

Sequelize relationship query returns duplicate data

I’m querying customer orders for a specified customer using Sequelize relationships.

index.js

JavaScript

service.js

JavaScript

results

JavaScript

expected

JavaScript

Advertisement

Answer

All you need is to remove raw: true, from query ,

as it will return plain/flat object , and that will convert your object as it looks now.

JavaScript

Note : You should put the where condition in upper level as per your logic

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