Library/models/authors_add.go
konrad cfcf4ac365 Insert methods now return the inserted object
Signed-off-by: kolaente <konrad@kola-entertainments.de>
2017-10-11 18:17:51 +02:00

14 lines
255 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
}