2017-10-11 15:20:56 +00:00
|
|
|
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) {
|
2017-10-11 15:20:56 +00:00
|
|
|
_, err = x.Insert(&author)
|
2017-10-11 16:17:51 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|