Library/models/authors_add.go

16 lines
314 B
Go

package models
// AddAuthor adds a new author based on an author struct
func AddAuthor(author Author) (newAuthor Author, err error) {
_, err = x.Insert(&author)
if err != nil {
return Author{}, err
}
// Get the newly inserted author
newAuthor, _, err = GetAuthorByID(author.ID)
return newAuthor, err
}