Add SongAlbumMap

This commit is contained in:
vfsfitvnm
2022-06-30 13:49:05 +02:00
parent 58f821534e
commit d07d3f23b2
8 changed files with 810 additions and 49 deletions

View File

@@ -6,8 +6,9 @@ import androidx.room.PrimaryKey
@Entity
data class Album(
@PrimaryKey val id: String,
val title: String,
val title: String?,
val thumbnailUrl: String?,
val year: String?,
val authorsText: String?
val authorsText: String?,
val shareUrl: String?
)

View File

@@ -8,14 +8,15 @@ import androidx.room.Relation
data class DetailedSong(
@Embedded val song: Song,
@Relation(
entity = Album::class,
parentColumn = "albumId",
entityColumn = "id"
) val album: Album?,
entity = SongAlbumMap::class,
entityColumn = "songId",
parentColumn = "id"
)
val albumId: String?,
@Relation(
entity = Artist::class,
parentColumn = "id",
entityColumn = "id",
parentColumn = "id",
associateBy = Junction(
value = SongArtistMap::class,
parentColumn = "songId",

View File

@@ -3,20 +3,10 @@ package it.vfsfitvnm.vimusic.models
import androidx.room.*
@Entity(
foreignKeys = [
ForeignKey(
entity = Album::class,
parentColumns = ["id"],
childColumns = ["albumId"],
onDelete = ForeignKey.SET_NULL
),
]
)
@Entity
data class Song(
@PrimaryKey val id: String,
val title: String,
val albumId: String?,
val artistsText: String? = null,
val durationText: String,
val thumbnailUrl: String?,

View File

@@ -0,0 +1,31 @@
package it.vfsfitvnm.vimusic.models
import androidx.compose.runtime.Immutable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
@Immutable
@Entity(
primaryKeys = ["songId", "albumId"],
foreignKeys = [
ForeignKey(
entity = Song::class,
parentColumns = ["id"],
childColumns = ["songId"],
onDelete = ForeignKey.CASCADE
),
ForeignKey(
entity = Album::class,
parentColumns = ["id"],
childColumns = ["albumId"],
onDelete = ForeignKey.CASCADE
)
]
)
data class SongAlbumMap(
@ColumnInfo(index = true) val songId: String,
@ColumnInfo(index = true) val albumId: String,
val position: Int?
)