Library/models/authors_delete.go

17 lines
318 B
Go
Raw Normal View History

package models
2017-11-08 09:55:17 +00:00
// DeleteAuthorByID deletes an author by its ID
2017-11-07 15:35:10 +00:00
func DeleteAuthorByID(id int64) error {
// Delete the author
_, err := x.Id(id).Delete(&Author{})
if err != nil {
return err
}
// Delete all book relations associated with that author
2017-11-07 15:35:10 +00:00
_, err = x.Delete(&AuthorBook{AuthorID: id})
return err
2017-11-07 15:35:10 +00:00
}