Library/models/authors_add.go

16 lines
314 B
Go
Raw Normal View History

package models
2017-11-08 09:55:17 +00:00
// AddAuthor adds a new author based on an author struct
2017-11-07 15:35:10 +00:00
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
2017-11-07 15:35:10 +00:00
}