1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-28 12:13:10 +00:00

simple usage of x (#3144)

This commit is contained in:
Lunny Xiao 2017-12-11 15:16:23 +08:00 committed by Lauris BH
parent 03ec35ed79
commit 956354885a

View file

@ -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)
}