Library/models/publishers_delete.go
kolaente a78ac5d7da Added methods to add and delete a publisher
Signed-off-by: kolaente <konrad@kola-entertainments.de>
2017-10-11 18:06:51 +02:00

19 lines
440 B
Go

package models
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
}