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
|
package models
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
// DeleteAuthorByID deletes an author by its ID
|
// DeleteAuthorByID deletes an author by its ID
|
||||||
func DeleteAuthorByID(id int64) error {
|
func DeleteAuthorByID(id int64) error {
|
||||||
|
// Check if the id is 0
|
||||||
|
if id == 0 {
|
||||||
|
return fmt.Errorf("ID cannot be 0")
|
||||||
|
}
|
||||||
|
|
||||||
// Delete the author
|
// Delete the author
|
||||||
_, err := x.Id(id).Delete(&Author{})
|
_, err := x.Id(id).Delete(&Author{})
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
// DeleteBookByID deletes a book by its ID
|
// DeleteBookByID deletes a book by its ID
|
||||||
func DeleteBookByID(id int64) error {
|
func DeleteBookByID(id int64) error {
|
||||||
|
// Check if the id is 0
|
||||||
|
if id == 0 {
|
||||||
|
return fmt.Errorf("ID cannot be 0")
|
||||||
|
}
|
||||||
|
|
||||||
// Delete the book
|
// Delete the book
|
||||||
_, err := x.Id(id).Delete(&Book{})
|
_, err := x.Id(id).Delete(&Book{})
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
// DeletePublisherByID deletes a publisher by its ID
|
// DeletePublisherByID deletes a publisher by its ID
|
||||||
func DeletePublisherByID(id int64) error {
|
func DeletePublisherByID(id int64) error {
|
||||||
|
// Check if the id is 0
|
||||||
|
if id == 0 {
|
||||||
|
return fmt.Errorf("ID cannot be 0")
|
||||||
|
}
|
||||||
|
|
||||||
// Delete the publisher
|
// Delete the publisher
|
||||||
_, err := x.Id(id).Delete(&Publisher{})
|
_, err := x.Id(id).Delete(&Publisher{})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue