Your Question
Is it expected that the data in the AfterUpdate/AfterSave hooks only have the changed fields? I'm looking to provide real time updates of data, should I use the hook to perform a find after save to get the full data or just always include the primary key value in the update so I have something to merge on?
I would expect that at least primary keys would be populated.
The document you expected this should be explained
https://gorm.io/docs/hooks.html
Expected answer
What data should or should not be present to the hook function.
Comment From: jinzhu
It can only have the changed field or it requires another query SQL.
Comment From: catsofmath
Newbie question: in AfterUpdate how do get the original record?
Say I have something like
func (newUser *User) AfterUpdate(tx *gorm.DB) (err error) {
// what should go here to get the original record?
}
I'm calling something without an ID in my update
db.Model(&model.User{}).Where("id = ?", 3).Updates(model.User{Age: 30})