Skip to content

Tag: sequelize.js

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: 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

Order By two columns but have one order

This question is sequelize specific but I’d figure if I found a way to do in SQL then I could find a way to do it in sequelize I need for the request to be ordered back by user.fullname which is joined by using include and by mockUser.fullname which is a JSON field. One important thing to keep in mind

SQL Query return extra column depending of condition

I want to make a query which will add a column depending of what condition is meet(I have tried with sequelize without obtaining the result that I wanted) therefore I want to try with plain SQL because It does not have as many limitations. EXAMPLE: SELECT * FROM db.messages WHERE user_id = userID OR $contacts…

N:M Relationship between users and guests

I’m building an app that can assign guests to an existing user. Those guests can see some information about the users they are associated with. It’s N:M: Users can have multiple guests associated Guests can be associated to multiple users Under the hood they are stored in the same table, the only …