In this particular case a fragment/1
is only really necessary for the right side of the :lateral_join
. One advantage of doing that is that you can push some of the work back to Ecto.
Example:
latest_albums_query = from(q in subquery(latest_artists_query), [
left_lateral_join: lal in fragment("SELECT id FROM albums AS al WHERE al.artist_id = ? ORDER BY al.inserted_at DESC NULLS LAST LIMIT ?", q.id, ^albums_limit), on: true,
join: al in Album, on: lal.id == al.id,
select: al # only an ecto struct can be used in subquery
])
Full Example:
iex(1)> alias MusicDB.{Repo,Album,Track}
[MusicDB.Repo, MusicDB.Album, MusicDB.Track]
iex(2)> import Ecto.Query
Ecto.Query
iex(3)> forget_assoc = fn ecto_struct, field, cardinality ->
...(3)> not_loaded = %Ecto.Association.NotLoaded{
...(3)> __field__: field,
...(3)> __owner__: ecto_struct.__struct__,
...(3)> __cardinality__: cardinality
...(3)> }
...(3)> Map.put(ecto_struct, field, not_loaded)
...(3)> end
#Function<18.127694169/3 in :erl_eval.expr/5>
iex(4)> forget_artist = &(forget_assoc.(&1, :artist, :one))
#Function<6.127694169/1 in :erl_eval.expr/5>
iex(5)> compact_to_rest = fn
...(5)> {nil, nil, rest} ->
...(5)> rest
...(5)> {artist, albums, rest} ->
...(5)> [Map.put(artist, :albums, albums)|rest] # NOTE: could reverse albums here
...(5)> end
#Function<6.127694169/1 in :erl_eval.expr/5>
iex(6)> row_to_acc = fn
...(6)> (%MusicDB.Album{artist: %MusicDB.Artist{id: id}} = a, {%MusicDB.Artist{id: id} = artist, albums, rest}) ->
...(6)> {artist, [forget_artist.(a)|albums], rest}
...(6)> (album, acc) ->
...(6)> {album.artist, [forget_artist.(album)], compact_to_rest.(acc)}
...(6)> end
#Function<12.127694169/2 in :erl_eval.expr/5>
iex(7)> make_result = fn rows ->
...(7)> rows
...(7)> |> List.foldl({nil, nil, []}, row_to_acc)
...(7)> |> compact_to_rest.() # NOTE: could reverse artists after this
...(7)> end
#Function<6.127694169/1 in :erl_eval.expr/5>
iex(8)> artists_limit = 2
2
iex(9)> albums_limit = 2
2
iex(10)> latest_artists_query = from(ar in Artist, [
...(10)> order_by: [desc: ar.inserted_at],
...(10)> limit: ^artists_limit
...(10)> ])
#Ecto.Query<from a in MusicDB.Artist, order_by: [desc: a.inserted_at],
limit: ^2>
iex(11)> latest_albums_query = from(q in subquery(latest_artists_query), [
...(11)> left_lateral_join: lal in fragment("SELECT id FROM albums AS al WHERE al.artist_id = ? ORDER BY al.inserted_at DESC NULLS LAST LIMIT ?", q.id, ^albums_limit), on: true,
...(11)> join: al in Album, on: lal.id == al.id,
...(11)> select: al # only an ecto struct can be used in subquery
...(11)> ])
#Ecto.Query<from a0 in subquery(from a in MusicDB.Artist,
order_by: [desc: a.inserted_at],
limit: ^2),
left_join_lateral: f in fragment("SELECT id FROM albums AS al WHERE al.artist_id = ? ORDER BY al.inserted_at DESC NULLS LAST LIMIT ?", a0.id, ^2),
on: true, join: a1 in MusicDB.Album, on: f.id == a1.id, select: a1>
iex(12)> query = from(p in subquery(latest_albums_query), [
...(12)> preload: [:tracks, :artist],
...(12)> order_by: [asc: :artist_id, asc: :inserted_at] # NOTE: order deliberately reversed for later processing
...(12)> ])
#Ecto.Query<from a in subquery(from a0 in subquery(from a in MusicDB.Artist,
order_by: [desc: a.inserted_at],
limit: ^2),
left_join_lateral: f in fragment("SELECT id FROM albums AS al WHERE al.artist_id = ? ORDER BY al.inserted_at DESC NULLS LAST LIMIT ?", a0.id, ^2),
on: true,
join: a1 in MusicDB.Album,
on: f.id == a1.id,
select: a1),
order_by: [asc: a.artist_id, asc: a.inserted_at], preload: [:artist, :tracks]>
iex(13)> rows = Repo.all(query)
12:19:29.805 [debug] QUERY OK db=3.5ms
SELECT s0."id", s0."title", s0."inserted_at", s0."updated_at", s0."artist_id" FROM (SELECT a2."id" AS "id", a2."title" AS "title", a2."inserted_at" AS "inserted_at", a2."updated_at" AS "updated_at", a2."artist_id" AS "artist_id" FROM (SELECT a0."id" AS "id", a0."name" AS "name", a0."birth_date" AS "birth_date", a0."death_date" AS "death_date", a0."inserted_at" AS "inserted_at", a0."updated_at" AS "updated_at" FROM "artists" AS a0 ORDER BY a0."inserted_at" DESC LIMIT $1) AS s0 LEFT OUTER JOIN LATERAL (SELECT id FROM albums AS al WHERE al.artist_id = s0."id" ORDER BY al.inserted_at DESC NULLS LAST LIMIT $2) AS f1 ON TRUE INNER JOIN "albums" AS a2 ON f1."id" = a2."id") AS s0 ORDER BY s0."artist_id", s0."inserted_at" [2, 2]
12:19:29.816 [debug] QUERY OK source="artists" db=1.7ms decode=1.6ms
SELECT a0."id", a0."name", a0."birth_date", a0."death_date", a0."inserted_at", a0."updated_at", a0."id" FROM "artists" AS a0 WHERE (a0."id" = ANY($1)) [[3, 2]]
12:19:29.816 [debug] QUERY OK source="tracks" db=1.0ms decode=1.8ms
SELECT t0."id", t0."title", t0."duration", t0."index", t0."number_of_plays", t0."inserted_at", t0."updated_at", t0."album_id", t0."album_id" FROM "tracks" AS t0 WHERE (t0."album_id" = ANY($1)) ORDER BY t0."album_id" [[5, 4, 3]]
[
%MusicDB.Album{
__meta__: #Ecto.Schema.Metadata<:loaded, "albums">,
artist: %MusicDB.Artist{
__meta__: #Ecto.Schema.Metadata<:loaded, "artists">,
albums: #Ecto.Association.NotLoaded<association :albums is not loaded>,
birth_date: nil,
death_date: nil,
id: 2,
inserted_at: ~N[2018-06-16 20:29:41.481934],
name: "Bill Evans",
tracks: #Ecto.Association.NotLoaded<association :tracks is not loaded>,
updated_at: ~N[2018-06-16 20:29:41.481940]
},
artist_id: 2,
genres: #Ecto.Association.NotLoaded<association :genres is not loaded>,
id: 3,
inserted_at: ~N[2018-06-16 20:29:41.483682],
title: "You Must Believe In Spring",
tracks: [
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 192,
duration_string: nil,
id: 11,
index: 1,
inserted_at: ~N[2018-06-16 20:29:41.486309],
number_of_plays: 0,
title: "B Minor Waltz (for Ellaine)",
updated_at: ~N[2018-06-16 20:29:41.486320]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 337,
duration_string: nil,
id: 12,
index: 2,
inserted_at: ~N[2018-06-16 20:29:41.487337],
number_of_plays: 0,
title: "You Must Believe In Spring",
updated_at: ~N[2018-06-16 20:29:41.487343]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 255,
duration_string: nil,
id: 13,
index: 3,
inserted_at: ~N[2018-06-16 20:29:41.487989],
number_of_plays: 0,
title: "Gary's Theme",
updated_at: ~N[2018-06-16 20:29:41.487996]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 239,
duration_string: nil,
id: 14,
index: 4,
inserted_at: ~N[2018-06-16 20:29:41.488686],
number_of_plays: 0,
title: "We Will Meet Again (for Harry)",
updated_at: ~N[2018-06-16 20:29:41.488695]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 360,
duration_string: nil,
id: 15,
index: 5,
inserted_at: ~N[2018-06-16 20:29:41.489335],
number_of_plays: 0,
title: "The Peacocks",
updated_at: ~N[2018-06-16 20:29:41.489342]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 292,
duration_string: nil,
id: 16,
index: 6,
inserted_at: ~N[2018-06-16 20:29:41.490017],
number_of_plays: 0,
title: "Sometime Ago",
updated_at: ~N[2018-06-16 20:29:41.490023]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 353,
duration_string: nil,
id: 17,
index: 7,
inserted_at: ~N[2018-06-16 20:29:41.490832],
number_of_plays: 0,
title: "Theme From M*A*S*H (Suicide Is Painless)",
updated_at: ~N[2018-06-16 20:29:41.490838]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 485,
duration_string: nil,
id: 18,
index: 8,
inserted_at: ~N[2018-06-16 20:29:41.491450],
number_of_plays: 0,
title: "Without a Song",
updated_at: ~N[2018-06-16 20:29:41.491456]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 454,
duration_string: nil,
id: 19,
index: 9,
inserted_at: ~N[2018-06-16 20:29:41.492091],
number_of_plays: 0,
title: "Freddie Freeloader",
updated_at: ~N[2018-06-16 20:29:41.492097]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 489,
duration_string: nil,
id: 20,
index: 10,
inserted_at: ~N[2018-06-16 20:29:41.492703],
number_of_plays: 0,
title: "All of You",
updated_at: ~N[2018-06-16 20:29:41.492708]
}
],
updated_at: ~N[2018-06-16 20:29:41.483713]
},
%MusicDB.Album{
__meta__: #Ecto.Schema.Metadata<:loaded, "albums">,
artist: %MusicDB.Artist{
__meta__: #Ecto.Schema.Metadata<:loaded, "artists">,
albums: #Ecto.Association.NotLoaded<association :albums is not loaded>,
birth_date: nil,
death_date: nil,
id: 2,
inserted_at: ~N[2018-06-16 20:29:41.481934],
name: "Bill Evans",
tracks: #Ecto.Association.NotLoaded<association :tracks is not loaded>,
updated_at: ~N[2018-06-16 20:29:41.481940]
},
artist_id: 2,
genres: #Ecto.Association.NotLoaded<association :genres is not loaded>,
id: 4,
inserted_at: ~N[2018-06-16 20:29:41.493342],
title: "Portrait In Jazz",
tracks: [
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 204,
duration_string: nil,
id: 21,
index: 1,
inserted_at: ~N[2018-06-16 20:29:41.494540],
number_of_plays: 0,
title: "Come Rain Or Come Shine",
updated_at: ~N[2018-06-16 20:29:41.494546]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 360,
duration_string: nil,
id: 22,
index: 2,
inserted_at: ~N[2018-06-16 20:29:41.495221],
number_of_plays: 0,
title: "Autumn Leaves",
updated_at: ~N[2018-06-16 20:29:41.495227]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 277,
duration_string: nil,
id: 23,
index: 3,
inserted_at: ~N[2018-06-16 20:29:41.495758],
number_of_plays: 0,
title: "Witchcraft",
updated_at: ~N[2018-06-16 20:29:41.495763]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 297,
duration_string: nil,
id: 24,
index: 4,
inserted_at: ~N[2018-06-16 20:29:41.496319],
number_of_plays: 0,
title: "When I Fall In Love",
updated_at: ~N[2018-06-16 20:29:41.496325]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 195,
duration_string: nil,
id: 25,
index: 5,
inserted_at: ~N[2018-06-16 20:29:41.496865],
number_of_plays: 0,
title: "Peri's Scope",
updated_at: ~N[2018-06-16 20:29:41.496871]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 276,
duration_string: nil,
id: 26,
index: 6,
inserted_at: ~N[2018-06-16 20:29:41.497420],
number_of_plays: 0,
title: "What Is This Thing Called Love?",
updated_at: ~N[2018-06-16 20:29:41.497425]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 309,
duration_string: nil,
id: 27,
index: 7,
inserted_at: ~N[2018-06-16 20:29:41.497956],
number_of_plays: 0,
title: "Spring Is Here",
updated_at: ~N[2018-06-16 20:29:41.497962]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 297,
duration_string: nil,
id: 28,
index: 8,
inserted_at: ~N[2018-06-16 20:29:41.498504],
number_of_plays: 0,
title: "Someday My Prince Will Come",
updated_at: ~N[2018-06-16 20:29:41.498510]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 325,
duration_string: nil,
id: 29,
index: 9,
inserted_at: ~N[2018-06-16 20:29:41.499008],
number_of_plays: 0,
title: "Blue In Green",
updated_at: ~N[2018-06-16 20:29:41.499013]
}
],
updated_at: ~N[2018-06-16 20:29:41.493348]
},
%MusicDB.Album{
__meta__: #Ecto.Schema.Metadata<:loaded, "albums">,
artist: %MusicDB.Artist{
__meta__: #Ecto.Schema.Metadata<:loaded, "artists">,
albums: #Ecto.Association.NotLoaded<association :albums is not loaded>,
birth_date: nil,
death_date: nil,
id: 3,
inserted_at: ~N[2018-06-16 20:29:41.500306],
name: "Bobby Hutcherson",
tracks: #Ecto.Association.NotLoaded<association :tracks is not loaded>,
updated_at: ~N[2018-06-16 20:29:41.500311]
},
artist_id: 3,
genres: #Ecto.Association.NotLoaded<association :genres is not loaded>,
id: 5,
inserted_at: ~N[2018-06-16 20:29:41.502041],
title: "Live At Montreaux",
tracks: [
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 5,
duration: 761,
duration_string: nil,
id: 30,
index: 1,
inserted_at: ~N[2018-06-16 20:29:41.506102],
number_of_plays: 0,
title: "Anton's Ball",
updated_at: ~N[2018-06-16 20:29:41.506109]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 5,
duration: 647,
duration_string: nil,
id: 31,
index: 2,
inserted_at: ~N[2018-06-16 20:29:41.507174],
number_of_plays: 0,
title: "The Moontrane",
updated_at: ~N[2018-06-16 20:29:41.507181]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 5,
duration: 805,
duration_string: nil,
id: 32,
index: 3,
inserted_at: ~N[2018-06-16 20:29:41.507927],
number_of_plays: 0,
title: "Farallone",
updated_at: ~N[2018-06-16 20:29:41.507934]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 5,
duration: 844,
duration_string: nil,
id: 33,
index: 4,
inserted_at: ~N[2018-06-16 20:29:41.508548],
number_of_plays: 0,
title: "Song Of Songs",
updated_at: ~N[2018-06-16 20:29:41.508554]
}
],
updated_at: ~N[2018-06-16 20:29:41.502048]
}
]
iex(14)> result = make_result.(rows)
[
%MusicDB.Artist{
__meta__: #Ecto.Schema.Metadata<:loaded, "artists">,
albums: [
%MusicDB.Album{
__meta__: #Ecto.Schema.Metadata<:loaded, "albums">,
artist: #Ecto.Association.NotLoaded<association :artist is not loaded>,
artist_id: 3,
genres: #Ecto.Association.NotLoaded<association :genres is not loaded>,
id: 5,
inserted_at: ~N[2018-06-16 20:29:41.502041],
title: "Live At Montreaux",
tracks: [
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 5,
duration: 761,
duration_string: nil,
id: 30,
index: 1,
inserted_at: ~N[2018-06-16 20:29:41.506102],
number_of_plays: 0,
title: "Anton's Ball",
updated_at: ~N[2018-06-16 20:29:41.506109]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 5,
duration: 647,
duration_string: nil,
id: 31,
index: 2,
inserted_at: ~N[2018-06-16 20:29:41.507174],
number_of_plays: 0,
title: "The Moontrane",
updated_at: ~N[2018-06-16 20:29:41.507181]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 5,
duration: 805,
duration_string: nil,
id: 32,
index: 3,
inserted_at: ~N[2018-06-16 20:29:41.507927],
number_of_plays: 0,
title: "Farallone",
updated_at: ~N[2018-06-16 20:29:41.507934]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 5,
duration: 844,
duration_string: nil,
id: 33,
index: 4,
inserted_at: ~N[2018-06-16 20:29:41.508548],
number_of_plays: 0,
title: "Song Of Songs",
updated_at: ~N[2018-06-16 20:29:41.508554]
}
],
updated_at: ~N[2018-06-16 20:29:41.502048]
}
],
birth_date: nil,
death_date: nil,
id: 3,
inserted_at: ~N[2018-06-16 20:29:41.500306],
name: "Bobby Hutcherson",
tracks: #Ecto.Association.NotLoaded<association :tracks is not loaded>,
updated_at: ~N[2018-06-16 20:29:41.500311]
},
%MusicDB.Artist{
__meta__: #Ecto.Schema.Metadata<:loaded, "artists">,
albums: [
%MusicDB.Album{
__meta__: #Ecto.Schema.Metadata<:loaded, "albums">,
artist: #Ecto.Association.NotLoaded<association :artist is not loaded>,
artist_id: 2,
genres: #Ecto.Association.NotLoaded<association :genres is not loaded>,
id: 4,
inserted_at: ~N[2018-06-16 20:29:41.493342],
title: "Portrait In Jazz",
tracks: [
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 204,
duration_string: nil,
id: 21,
index: 1,
inserted_at: ~N[2018-06-16 20:29:41.494540],
number_of_plays: 0,
title: "Come Rain Or Come Shine",
updated_at: ~N[2018-06-16 20:29:41.494546]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 360,
duration_string: nil,
id: 22,
index: 2,
inserted_at: ~N[2018-06-16 20:29:41.495221],
number_of_plays: 0,
title: "Autumn Leaves",
updated_at: ~N[2018-06-16 20:29:41.495227]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 277,
duration_string: nil,
id: 23,
index: 3,
inserted_at: ~N[2018-06-16 20:29:41.495758],
number_of_plays: 0,
title: "Witchcraft",
updated_at: ~N[2018-06-16 20:29:41.495763]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 297,
duration_string: nil,
id: 24,
index: 4,
inserted_at: ~N[2018-06-16 20:29:41.496319],
number_of_plays: 0,
title: "When I Fall In Love",
updated_at: ~N[2018-06-16 20:29:41.496325]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 195,
duration_string: nil,
id: 25,
index: 5,
inserted_at: ~N[2018-06-16 20:29:41.496865],
number_of_plays: 0,
title: "Peri's Scope",
updated_at: ~N[2018-06-16 20:29:41.496871]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 276,
duration_string: nil,
id: 26,
index: 6,
inserted_at: ~N[2018-06-16 20:29:41.497420],
number_of_plays: 0,
title: "What Is This Thing Called Love?",
updated_at: ~N[2018-06-16 20:29:41.497425]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 309,
duration_string: nil,
id: 27,
index: 7,
inserted_at: ~N[2018-06-16 20:29:41.497956],
number_of_plays: 0,
title: "Spring Is Here",
updated_at: ~N[2018-06-16 20:29:41.497962]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 297,
duration_string: nil,
id: 28,
index: 8,
inserted_at: ~N[2018-06-16 20:29:41.498504],
number_of_plays: 0,
title: "Someday My Prince Will Come",
updated_at: ~N[2018-06-16 20:29:41.498510]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 4,
duration: 325,
duration_string: nil,
id: 29,
index: 9,
inserted_at: ~N[2018-06-16 20:29:41.499008],
number_of_plays: 0,
title: "Blue In Green",
updated_at: ~N[2018-06-16 20:29:41.499013]
}
],
updated_at: ~N[2018-06-16 20:29:41.493348]
},
%MusicDB.Album{
__meta__: #Ecto.Schema.Metadata<:loaded, "albums">,
artist: #Ecto.Association.NotLoaded<association :artist is not loaded>,
artist_id: 2,
genres: #Ecto.Association.NotLoaded<association :genres is not loaded>,
id: 3,
inserted_at: ~N[2018-06-16 20:29:41.483682],
title: "You Must Believe In Spring",
tracks: [
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 192,
duration_string: nil,
id: 11,
index: 1,
inserted_at: ~N[2018-06-16 20:29:41.486309],
number_of_plays: 0,
title: "B Minor Waltz (for Ellaine)",
updated_at: ~N[2018-06-16 20:29:41.486320]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 337,
duration_string: nil,
id: 12,
index: 2,
inserted_at: ~N[2018-06-16 20:29:41.487337],
number_of_plays: 0,
title: "You Must Believe In Spring",
updated_at: ~N[2018-06-16 20:29:41.487343]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 255,
duration_string: nil,
id: 13,
index: 3,
inserted_at: ~N[2018-06-16 20:29:41.487989],
number_of_plays: 0,
title: "Gary's Theme",
updated_at: ~N[2018-06-16 20:29:41.487996]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 239,
duration_string: nil,
id: 14,
index: 4,
inserted_at: ~N[2018-06-16 20:29:41.488686],
number_of_plays: 0,
title: "We Will Meet Again (for Harry)",
updated_at: ~N[2018-06-16 20:29:41.488695]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 360,
duration_string: nil,
id: 15,
index: 5,
inserted_at: ~N[2018-06-16 20:29:41.489335],
number_of_plays: 0,
title: "The Peacocks",
updated_at: ~N[2018-06-16 20:29:41.489342]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 292,
duration_string: nil,
id: 16,
index: 6,
inserted_at: ~N[2018-06-16 20:29:41.490017],
number_of_plays: 0,
title: "Sometime Ago",
updated_at: ~N[2018-06-16 20:29:41.490023]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 353,
duration_string: nil,
id: 17,
index: 7,
inserted_at: ~N[2018-06-16 20:29:41.490832],
number_of_plays: 0,
title: "Theme From M*A*S*H (Suicide Is Painless)",
updated_at: ~N[2018-06-16 20:29:41.490838]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 485,
duration_string: nil,
id: 18,
index: 8,
inserted_at: ~N[2018-06-16 20:29:41.491450],
number_of_plays: 0,
title: "Without a Song",
updated_at: ~N[2018-06-16 20:29:41.491456]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 454,
duration_string: nil,
id: 19,
index: 9,
inserted_at: ~N[2018-06-16 20:29:41.492091],
number_of_plays: 0,
title: "Freddie Freeloader",
updated_at: ~N[2018-06-16 20:29:41.492097]
},
%MusicDB.Track{
__meta__: #Ecto.Schema.Metadata<:loaded, "tracks">,
album: #Ecto.Association.NotLoaded<association :album is not loaded>,
album_id: 3,
duration: 489,
duration_string: nil,
id: 20,
index: 10,
inserted_at: ~N[2018-06-16 20:29:41.492703],
number_of_plays: 0,
title: "All of You",
updated_at: ~N[2018-06-16 20:29:41.492708]
}
],
updated_at: ~N[2018-06-16 20:29:41.483713]
}
],
birth_date: nil,
death_date: nil,
id: 2,
inserted_at: ~N[2018-06-16 20:29:41.481934],
name: "Bill Evans",
tracks: #Ecto.Association.NotLoaded<association :tracks is not loaded>,
updated_at: ~N[2018-06-16 20:29:41.481940]
}
]
iex(15)>