Alias for M2M Relations #255
-
|
I'm trying to get bob to generate a custom alias for a m2m relation with a join table. I couldn't figure out how to get it working from the documentation itself: https://bob.stephenafamo.com/docs/code-generation/configuration#aliases So with the following tables: By default the relation will be called TeamUsers so e.g. How do I need to properly set the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
In the generated code, you will see the relationship key in a comment in the // videoR is where relationships are stored.
type videoR struct {
Tags TagSlice // video_tags.video_tags_tag_id_fkeyvideo_tags.video_tags_video_id_fkey
Sponsor *Sponsor // videos.videos_sponsor_id_fkey
User *User // videos.videos_user_id_fkey
}Use that in the configuration: aliases:
team:
relationships:
"video_tags.video_tags_tag_id_fkeyvideo_tags.video_tags_video_id_fkey": "Owner" |
Beta Was this translation helpful? Give feedback.
In the generated code, you will see the relationship key in a comment in the
modelRstruct. For example:Use that in the configuration: