From 4075ae07cc006a3c7c01e5bf70871d506d1dfed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bokun=20Wang=20=E7=8E=8B=E5=8D=9A=E5=9D=A4?= Date: Fri, 31 Jul 2020 14:10:43 +0800 Subject: [PATCH] update --- db/mysql/mysql.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/mysql/mysql.go b/db/mysql/mysql.go index 82a55ec..12ba4cc 100644 --- a/db/mysql/mysql.go +++ b/db/mysql/mysql.go @@ -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