1
votes

I recently started using Sequelize for my Nodejs (express) backend of my VueJS project

The sql query below gives me what I need from my database (mysql) but I don't know how to translate this to Sequelize can anybody help me?

SELECT u.*, GROUP_CONCAT(ui.instrument_name ORDER BY ui.instrument_name) 
AS instruments 
FROM Users u 
INNER JOIN user_instruments ui 
ON ui.user_id = u.id 
INNER JOIN Instruments i 
ON i.instrument_name = ui.instrument_name 
GROUP BY u.id
1

1 Answers

0
votes

you can use the raw sql query in sequelize by using query method.

meaning you can use this as your query directly by

sequelize.query('YOUR SQL QUERY')

checkout the sequelize doc link