Skip to content

Commit

Permalink
Merge pull request #1 from zsinx/master
Browse files Browse the repository at this point in the history
change updates function of template
  • Loading branch information
xjellyx authored Aug 17, 2021
2 parents 0a46555 + 6f9c01a commit d25f264
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion example/gen_admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (t *Admin) Delete(db *gorm.DB) (err error) {

// Updates update record
func (t *Admin) Updates(db *gorm.DB, m map[string]interface{}) (err error) {
if err = db.Model(&Admin{}).Where("id = ?", t.ID).Updates(m).Error; err != nil {
if err = db.Model(t).Updates(m).Error; err != nil {

err = ErrUpdateAdmin
return
Expand Down
2 changes: 1 addition & 1 deletion example/gen_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (t *User) Delete(db *gorm.DB) (err error) {

// Updates update record
func (t *User) Updates(db *gorm.DB, m map[string]interface{}) (err error) {
if err = db.Model(&User{}).Where("id = ?", t.ID).Updates(m).Error; err != nil {
if err = db.Model(t).Updates(m).Error; err != nil {

err = ErrUpdateUser
return
Expand Down
2 changes: 1 addition & 1 deletion template.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import (
// Updates update record
func (t *{{.StructName}}) Updates(db *gorm.DB, m map[string]interface{})(err error) {
if err = db.Model(&{{.StructName}}{}).Where("id = ?",t.ID).Updates(m).Error;err!=nil{
if err = db.Model(t).Updates(m).Error;err!=nil{
{{if $LogName}} {{ $LogName}}.Errorln(err) {{end}}
{{if $TransformErr}} err = ErrUpdate{{.StructName}} {{end}}
return
Expand Down

0 comments on commit d25f264

Please sign in to comment.