I'm new to ORM and I don't know to do this using an ORM. Considering that i have 5 tables:
tag, auction, user, user_tag and auction_tag
and I'm using SequelizeJS, how can I get a query like this?
select A.id, A.title, A.content, A.createdAt, U.id, U.picture, U.name
from Auction A, User U, User U2
where A.userId = U.id and U2.id = x
and exists (select AT.id
from Auction_Tag AT
where AT.auction = A.id
and AT.tag in ( select T.id
from Tag T, User_Tag UT
where U2.id = UT.user
and UT.tag = T.id
)
);
Any ideas? Thank you guys
sequelize.query("SELECT * FROMusers", { type: sequelize.QueryTypes.SELECT}) .then(function(users) { // We don't need spread here, since only the results will be returned for select queries })