I have the update code like this:
db.Model(&models.DailyPlan{}).
Where("daily_plan_id IN ?", dailyPlanIds).
Updates(updateClause).Error
and hooks:
func (d *DailyPlan) AfterSave(tx *gorm.DB) (err error) {
// blah bla开发者_运维百科h
return
}
But when I run the update code above, in my hooks, I cannot get the ID (daily_plan_id
) (only the fields in the updateClause
have data).
How can I get the ID that I send in dailyPlanIds
?
You can use Set/Get
based on here
精彩评论