I’ve the next tables:
sort OldData struct {
Title string
Date time.Time
}
sort NewData struct {
gorm.Mannequin
Title string
}
sort Historical past struct {
ID uint
Date time.Time
}
So then I’ve a state of affairs just like this:
oldData := &OldData{
Title: "Julia",
Date: time.Now(),
}
newData := &NewData{
Title: oldData.Title,
}
historical past := &Historical past{
Date: oldData.Date,
}
How do I create the brand new newData row however on the similar time have historical past.ID be the identical ID as newData.ID? How do I make a relationship in order that if I delete the newData.ID row the historical past.ID row can be deleted from the historys desk?
I’m in search of a solution to relate newData to historical past which can be saved in two completely different tables.db.Create(newData)