Added check if the ID is empty when deleting
the build was successful
Details
the build was successful
Details
This commit is contained in:
parent
9dcac2a5c2
commit
3aabf3b086
|
@ -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{})
|
||||
|
||||
|
|
|
@ -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{})
|
||||
|
||||
|
|
|
@ -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{})
|
||||
|
||||
|
|
Loading…
Reference in New Issue