Skip to content

Commit

Permalink
Add function to search artists by name similarity
Browse files Browse the repository at this point in the history
  • Loading branch information
blackfyre committed Oct 30, 2023
1 parent 9210ace commit 876e05d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions models/artist.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ func GetArtistBySlug(dao *daos.Dao, slug string) (*Artist, error) {
return &c, err
}

func GetArtistByNameLike(dao *daos.Dao, name string) ([]*Artist, error) {
var c []*Artist
err := ArtistQuery(dao).AndWhere(dbx.NewExp("LOWER(name) LIKE {:name}", dbx.Params{
"name": "%" + name + "%",
})).All(&c)
return c, err
}

func GetArtistById(dao *daos.Dao, id string) (*Artist, error) {
var c Artist
err := ArtistQuery(dao).AndWhere(dbx.NewExp("id={:id}", dbx.Params{
Expand Down

0 comments on commit 876e05d

Please sign in to comment.