From 956354885a60abe82ac608e764fcb56d4016339e Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 11 Dec 2017 15:16:23 +0800 Subject: [PATCH] simple usage of x (#3144) --- models/attachment.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/models/attachment.go b/models/attachment.go index cadb23a5745..e7e0dbf5c2a 100644 --- a/models/attachment.go +++ b/models/attachment.go @@ -31,11 +31,8 @@ type Attachment struct { // IncreaseDownloadCount is update download count + 1 func (a *Attachment) IncreaseDownloadCount() error { - sess := x.NewSession() - defer sess.Close() - // Update download count. - if _, err := sess.Exec("UPDATE `attachment` SET download_count=download_count+1 WHERE id=?", a.ID); err != nil { + if _, err := x.Exec("UPDATE `attachment` SET download_count=download_count+1 WHERE id=?", a.ID); err != nil { return fmt.Errorf("increase attachment count: %v", err) }