Skip to content

Commit

Permalink
Merge pull request #39 from wangbokun/dev
Browse files Browse the repository at this point in the history
update
  • Loading branch information
wangbokun authored Jul 31, 2020
2 parents ad70dc5 + 4075ae0 commit 91c3a55
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions db/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,17 @@ func (my *MySQL) Update(ctx context.Context, table string, v interface{}, cond m
}

// Upset update if exist or insert, true is insert, false is update
func (my *MySQL) Upset(ctx context.Context, table string, v interface{}, cond map[string]interface{}) (bool, error) {
func (my *MySQL) Upset(ctx context.Context, table string, v interface{}, cond map[string]interface{}) (bool, error, sql.Result) {
result, err := my.Update(ctx, table, v, cond)
if err != nil {
return false, err
return false, err, nil
}
if n, err := result.RowsAffected(); err != nil || n != 0 {
return false, err
return false, err, result
}

_, err = my.Put(ctx, table, v)
return true, err
res, err := my.Put(ctx, table, v)
return true, err, res
}

// Get get data
Expand Down

0 comments on commit 91c3a55

Please sign in to comment.