Код: Выделить всё
@Entity
data class Playlist(
@PrimaryKey val playlistId: Long,
val playlistName: String
)
@Entity
data class Song(
@PrimaryKey val songId: Long,
val songName: String,
val artist: String
)
@Entity(primaryKeys = ["playlistId", "songId"])
data class PlaylistSongCrossRef(
val playlistId: Long,
val songId: Long,
val rating: Int //
@Dao
interface SongWithPlaylistsDao {
@Query("SELECT * FROM Song")
fun list(): LiveData
}
< /code>
Я знаю, как, с точки зрения ERM, вы бы моделировали эти отношения, как это: < /p>
/-- A ---\ /- ACrossB -\ /-- B ---\
| | | | | |
| - id |----->| - aId | |------| - id |
| - name | | - bId |-----| | -name |
| | | - prop | | |
\--------/ \-----------/ \--------/
Подробнее здесь: https://stackoverflow.com/questions/602 ... f-junction
Мобильная версия