Library/models/publishers_list.go
konrad 64dd0ce2d0
Some checks failed
the build failed
Fixed lint
2017-11-08 10:55:17 +01:00

20 lines
402 B
Go

package models
// ListPublishers returns a list with all publishers, filtered by an optional searchstring
func ListPublishers(searchterm string) (publishers []Publisher, err error) {
if searchterm == "" {
err = x.Find(&publishers)
} else {
err = x.
Where("name LIKE ?", "%"+searchterm+"%").
Find(&publishers)
}
if err != nil {
return []Publisher{}, err
}
return publishers, nil
}