Can search and paginate records

This commit is contained in:
Claudio Ortolina
2024-09-27 09:46:45 +01:00
parent 95164cd977
commit ae45ab44df
4 changed files with 103 additions and 40 deletions
+8
View File
@@ -35,6 +35,14 @@ defmodule MusicLibrary.Records do
Repo.aggregate(Record, :count)
end
def search_records_count(query) do
q =
from r in Record,
where: like(r.title, ^"%#{query}%") or like(r.artists, ^"%#{query}%")
Repo.aggregate(q, :count)
end
def get_record!(id), do: Repo.get!(Record, id)
def get_image!(id) do