package models // DeletePublisherByID deletes a publisher by its ID func DeletePublisherByID(id int64) error { // Delete the publisher _, err := x.Id(id).Delete(&Publisher{}) if err != nil { return err } // Set all publisher to 0 on all book with this publisher //book := Book{Publisher:0} //book.Publisher = 0 //_, err = x.Where("publisher = ?", id).Update(book) _, err = x.Table("books").Where("publisher = ?", id).Update(map[string]interface{}{"publisher": 0}) return err }