Library/models/authors_add.go

15 lines
257 B
Go

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