开发者

GORM hooks - Cannot get the ID when update multiple rows

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜