Added check if the ID is empty when deleting
the build was successful Details

This commit is contained in:
konrad 2017-11-24 16:27:35 +01:00 committed by kolaente
parent 9dcac2a5c2
commit 3aabf3b086
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 21 additions and 0 deletions

View File

@ -1,7 +1,14 @@
package models
import "fmt"
// DeleteAuthorByID deletes an author by its ID
func DeleteAuthorByID(id int64) error {
// Check if the id is 0
if id == 0 {
return fmt.Errorf("ID cannot be 0")
}
// Delete the author
_, err := x.Id(id).Delete(&Author{})

View File

@ -1,7 +1,14 @@
package models
import "fmt"
// DeleteBookByID deletes a book by its ID
func DeleteBookByID(id int64) error {
// Check if the id is 0
if id == 0 {
return fmt.Errorf("ID cannot be 0")
}
// Delete the book
_, err := x.Id(id).Delete(&Book{})

View File

@ -1,7 +1,14 @@
package models
import "fmt"
// DeletePublisherByID deletes a publisher by its ID
func DeletePublisherByID(id int64) error {
// Check if the id is 0
if id == 0 {
return fmt.Errorf("ID cannot be 0")
}
// Delete the publisher
_, err := x.Id(id).Delete(&Publisher{})