How can I populate a foreign key on a query in sequelize ( like is done in mongoose ) ( nodejs )

Viewed 146

In mongoose(node js) you can do something like

Post.findOne({owner_id:4}).populate('user') // mongoose

In this case(mongoose) the owner_id is a ObjectId referencing the a document in the user collection.And instead of returning and ID in the owner_id field, the query would return an object containing all the information about that user( because it would have been populated ).

I would like to know if its possible to do a population in sequelize. With Like

Post.findOne({where:{owner_id:4}}).populate('user') // sequelize
0 Answers
Related