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
}
