Consider I have BaseNotification
and ExtendedNotification
structs.
For some notifications they use base_notificaion
table only yet some of them will save some extra data into extended_notificaion
.
How to setup struct tag in these two structs so that when I run
db.Create(&entendedNotification) // or something else
GORM will know it need to insert a new tuple into extended_notification
if needed(for example either it is not nil
or fields are filled)
And when I call
db.Preload(`ExtendedNotification`).Find(¬ifications)
it will grab all necessary entities accordingly?