You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
696 B
Smarty

func (m *default{{.upperStartCamelObject}}Model) Update(ctx context.Context, tx *gorm.DB, data *{{.upperStartCamelObject}}) error {
{{if .withCache}}{{.keys}}
return m.ExecCtx(ctx, func(conn *gorm.DB) error {
result := gormx.WithTx(ctx, conn, tx).Save(data)
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
return gormx.ErrRowsAffectedZero
}
return nil
}, {{.keyValues}}){{else}}
result:=gormx.WithTx(ctx, m.DB, tx).Save(data)
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
return gormx.ErrRowsAffectedZero
}
return nil
{{end}}
}