This commit is contained in:
lbenedar
2026-03-18 17:29:42 +03:00
parent 17267ed145
commit c4df79dffa
3 changed files with 7 additions and 1 deletions

View File

@@ -138,12 +138,14 @@ func (m MovieModel) GetAll(title string, genres []string, filter Filters) ([]*Mo
query := `
SELECT id, created_at, title, year, runtime, genres, version
FROM movies
WHERE (to_tsvector('simple', title) @@ plainto_tsquery('simple', $1) OR $1 = '')
AND (genres @> $2 OR $2 = '{}')
ORDER BY id`
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
rows, err := m.DB.QueryContext(ctx, query)
rows, err := m.DB.QueryContext(ctx, query, title, pq.Array(genres))
if err != nil {
return nil, err
}