kolaente
3c08e18cd2
All checks were successful
the build was successful
+ Resolved quantity stuff - there now is a new table which links books or items to a quantity
24 lines
379 B
Go
24 lines
379 B
Go
package models
|
|
|
|
import "fmt"
|
|
|
|
// DeleteItemByID deletes a item by its ID
|
|
func DeleteItemByID(id int64) error {
|
|
// Check if the id is 0
|
|
if id == 0 {
|
|
return fmt.Errorf("ID cannot be 0")
|
|
}
|
|
|
|
// Delete the item
|
|
_, err := x.Id(id).Delete(&Item{})
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Delete all quantites for this item
|
|
_, err = x.Delete(&Quantity{ItemID: id})
|
|
|
|
return err
|
|
}
|