From 16348b0e79d50313deff21953ce500e17b30e1e1 Mon Sep 17 00:00:00 2001 From: Dumindu Madunuwan Date: Thu, 14 Sep 2023 18:01:59 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=B1Refactor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/resource/book/repository.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/api/resource/book/repository.go b/api/resource/book/repository.go index 4e85888..7f7d3e2 100644 --- a/api/resource/book/repository.go +++ b/api/resource/book/repository.go @@ -46,18 +46,9 @@ func (r *Repository) Read(id uuid.UUID) (*Book, error) { } func (r *Repository) Update(book *Book) error { - if err := r.db.Updates(book).Where("id = %s", book.ID).Error; err != nil { - return err - } - - return nil + return r.db.Updates(book).Where("id = %s", book.ID).Error } func (r *Repository) Delete(id uuid.UUID) error { - book := &Book{} - if err := r.db.Where("id = ?", id).Delete(&book).Error; err != nil { - return err - } - - return nil + return r.db.Where("id = ?", id).Delete(&Book{}).Error }