Returning nested object with hasMany relation

16 views
Skip to first unread message

Frederic Visticot

unread,
Aug 16, 2016, 9:01:59 AM8/16/16
to Sequelize
I would like to have the following data model:

1 Coupon 
1 Coupon template (to store common values of all coupons like image, max number of points)

When creating a coupon the id of the template is stored on the Coupon side

couponTemplate.hasMany(coupon);


Coupon model is successfully created with a CouponTemplateId field.


What do I need to do to find a coupon by ID and returning the nested CouponTemplate. Currenty, only the CouponTemplateId is return in the Coupon object


Reply all
Reply to author
Forward
0 new messages