refactor: change where to use a struct

This commit is contained in:
Derrick Hammer 2023-05-11 15:25:31 -04:00
parent 294370d88d
commit 435445dda5
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 2 additions and 2 deletions

View File

@ -46,7 +46,7 @@ func Upload(r io.ReadSeeker) (model.Upload, error) {
return upload, err return upload, err
} }
result := db.Get().Where("hash = ?", hashHex).First(&upload) result := db.Get().Where(&model.Upload{Hash: hashHex}).First(&upload)
if (result.Error != nil && result.Error.Error() != "record not found") || result.RowsAffected > 0 { if (result.Error != nil && result.Error.Error() != "record not found") || result.RowsAffected > 0 {
err := result.Row().Scan(&upload) err := result.Row().Scan(&upload)
if err != nil { if err != nil {
@ -98,7 +98,7 @@ func Upload(r io.ReadSeeker) (model.Upload, error) {
return upload, nil return upload, nil
} }
func Download(hash string) (io.Reader, error) { func Download(hash string) (io.Reader, error) {
result := db.Get().Table("uploads").Where("hash = ?", hash).Row() result := db.Get().Table("uploads").Where(&model.Upload{Hash: hash}).Row()
if result.Err() != nil { if result.Err() != nil {
return nil, result.Err() return nil, result.Err()