Skip to content

Instantly share code, notes, and snippets.

@jordanell
Created March 22, 2019 15:53
Show Gist options
  • Save jordanell/bf21422b28e510c71b41f11df5edf6c4 to your computer and use it in GitHub Desktop.
Save jordanell/bf21422b28e510c71b41f11df5edf6c4 to your computer and use it in GitHub Desktop.
Sequelize polymorphism eager loading
/**
* Given a comment which has polymorphic associations of post and photo.
*/
const comments = await models.Comment.findAll({
include: [
{ model: models.Photo },
{ model: models.Post },
],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment