19 lines
339 B
Go
19 lines
339 B
Go
package models
|
|
|
|
func ListAuthors(searchterm string) (authors []Author, err error) {
|
|
|
|
if searchterm == "" {
|
|
err = x.Find(&authors)
|
|
} else {
|
|
err = x.
|
|
Where("forename LIKE ?", "%"+searchterm+"%").
|
|
Or("lastname LIKE ?", "%"+searchterm+"%").
|
|
Find(&authors)
|
|
}
|
|
if err != nil {
|
|
return []Author{}, err
|
|
}
|
|
|
|
return authors, nil
|
|
}
|