Hi folks, how have you been?
Scenario:
- I’m working on a music solution (spotify like) and I’m generating a RDF file in order to import via bulk load, then, I have
SONG 1
that belongs to2 ALBUMS
(ALBUM 1 and ALBUM 2), mostly likely the track number won’t be the same in these albums. Currently I’m holding the track number in a “many to many table”SONG_X_ALBUMS(SONG_ID, ALBUM_ID)
in a relational database.
Question:
The question is: How can I sort it by tracknumber based on the source (parent,origin, etc…) edge?
That is the RDF sample I’m generating:
<SONG1> <dgraph.type> "SongModel" .
<SONG1> <Explicit> "false"^^<xs:boolean> .
<SONG1> <ID> "1"^^<xs:integer> .
<SONG1> <ReleaseDate> "2000-07-01T00:00:00Z"^^<xs:date> .
<SONG1> <Duration> "241"^^<xs:integer> .
<SONG1> <Year> "2000"^^<xs:integer> .
<SONG1> <Views> "110"^^<xs:integer> .
<SONG1> <OriginalTitle> "Revolcón"^^<xs:string> .
<SONG1> <Title> "Revolcón"^^<xs:string> .
<SONG1> <UUID> "SONG1"^^<xs:string> .
<SONG2> <dgraph.type> "SongModel" .
<SONG2> <Explicit> "false"^^<xs:boolean> .
<SONG2> <ID> "2"^^<xs:integer> .
<SONG2> <ReleaseDate> "2000-07-01T00:00:00Z"^^<xs:date> .
<SONG2> <Duration> "241"^^<xs:integer> .
<SONG2> <Year> "2000"^^<xs:integer> .
<SONG2> <Views> "110"^^<xs:integer> .
<SONG2> <OriginalTitle> "Revolcón"^^<xs:string> .
<SONG2> <Title> "Revolcón"^^<xs:string> .
<SONG1> <UUID> "SONG2"^^<xs:string> .
<ALBUM1> <dgraph.type> "AlbumModel" .
<ALBUM1> <ID> "1"^^<xs:integer> .
<ALBUM1> <ReleaseDate> "2000-07-01T00:00:00Z"^^<xs:date> .
<ALBUM1> <Duration> "2597"^^<xs:integer> .
<ALBUM1> <Year> "2000"^^<xs:integer> .
<ALBUM1> <Views> "2330"^^<xs:integer> .
<ALBUM1> <OriginalTitle> "Champetas de Mi Pueblo, Vol. 2"^^<xs:string> .
<ALBUM1> <Title> "Champetas de Mi Pueblo, Vol. 2"^^<xs:string> .
<ALBUM1> <UUID> "ALBUM1"^^<xs:string> .
<ALBUM2> <dgraph.type> "AlbumModel" .
<ALBUM2> <ID> "2"^^<xs:integer> .
<ALBUM2> <ReleaseDate> "2018-07-06T00:00:00Z"^^<xs:date> .
<ALBUM2> <Duration> "222"^^<xs:integer> .
<ALBUM2> <Year> "2018"^^<xs:integer> .
<ALBUM2> <Views> "120"^^<xs:integer> .
<ALBUM2> <OriginalTitle> "When It Feels Right"^^<xs:string> .
<ALBUM2> <Title> "When It Feels Right"^^<xs:string> .
<ALBUM2> <UUID> "ALBUM2"^^<xs:string> .
<ALBUM1> <Song> <SONG2> . <-- song2 track number here is 1
<ALBUM1> <Song> <SONG1> . <-- song1 track number here is 2
<ALBUM2> <Song> <SONG1> . <-- song1 track number here is 1
<ALBUM2> <Song> <SONG2> . <-- song2 track number here is 2
I know it is possible to do something like
me(func: eq(UUID, "ALBUM1")) {
Title
songs (orderasc: ?) { <- order by tracknumber based on album1?
uid
Title
}
}