Created
January 9, 2019 15:22
-
-
Save Eth3rnit3/e8b14e16bb974721e225a6275cf7eacd to your computer and use it in GitHub Desktop.
In this example, Product belongsTo Media and Category hasMany Product Media > Product > Category Product know mediaId
Product know categoryId
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Category.findByPk(req.params.id, { | |
include: [ | |
{ | |
model: Product, as: 'products', include: | |
[ | |
{model: Media, as: 'image'} | |
] | |
} | |
] | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment