How do I save/create a model with a relation? #3678
-
I have 2 models - User and Promo code. Models/PromoCode.ts
In the User model migration file:
I didn't specify anything else to link the two models.
In the PromoCode model migration file:
How do I create or save a model with a relation: one promo code -> many users?
How should I save/create/update a model instance with a relation? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
At a quick glance one thing I see that seems to be missing is a BelongsTo relation defined in the User model. |
Beta Was this translation helpful? Give feedback.
At a quick glance one thing I see that seems to be missing is a BelongsTo relation defined in the User model.
https://docs.adonisjs.com/guides/models/relationships#belongsto