Use ->> instead of json_extract in queries

Improves readability of queries.
This commit is contained in:
Claudio Ortolina
2025-06-06 21:05:44 +01:00
parent b83e23918c
commit a63f2de60b
4 changed files with 7 additions and 6 deletions
+3 -3
View File
@@ -78,11 +78,11 @@ defmodule MusicLibrary.Collection do
q =
from r in fragment("records, json_each(records.artists)"),
where: fragment("records.purchased_at IS NOT NULL"),
group_by: fragment("json_extract(?, '$.name')", r.value),
group_by: fragment("? ->> '$.name'", r.value),
order_by: [desc: fragment("count(1)")],
select: %{
id: fragment("json_extract(?, '$.musicbrainz_id')", r.value),
name: fragment("json_extract(?, '$.name')", r.value),
id: fragment("? ->> '$.musicbrainz_id'", r.value),
name: fragment("? ->> '$.name'", r.value),
count: fragment("count(1)")
},
limit: ^limit