Library/models/authors_update.go

16 lines
350 B
Go
Raw Normal View History

package models
2017-11-08 09:55:17 +00:00
// UpdateAuthor updates an author by its ID and a new author struct
2017-11-07 15:35:10 +00:00
func UpdateAuthor(author Author, id int64) (newAuthor Author, err error) {
_, err = x.Where("id = ?", id).Update(&author)
if err != nil {
return Author{}, err
}
// Get the newly updated author
newAuthor, _, err = GetAuthorByID(id)
return newAuthor, err
2017-11-07 15:35:10 +00:00
}