Add SongAlbumMap
This commit is contained in:
@@ -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?
|
||||
)
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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?,
|
||||
|
||||
@@ -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?
|
||||
)
|
||||
Reference in New Issue
Block a user