Developers Notes

My Journey as Software Architect

Sequelize CheatSheet

Join Queries

First, assign the related table in the model, you can put it on bottom of model, before export function

 

User.hasMany(Post, {foreignKey: 'user_id'})
Post.belongsTo(User, {foreignKey: 'user_id'})

then you can call it using

Post.find({ where: { ...}, include: [User]})

Source: 

Further reading: