26 lines
826 B
Kotlin
26 lines
826 B
Kotlin
package code.name.monkey.retromusic.db
|
|
|
|
import androidx.lifecycle.LiveData
|
|
import androidx.room.*
|
|
|
|
@Dao
|
|
interface HistoryDao {
|
|
companion object {
|
|
private const val HISTORY_LIMIT = 100
|
|
}
|
|
|
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
|
suspend fun insertSongInHistory(historyEntity: HistoryEntity)
|
|
|
|
@Query("SELECT * FROM HistoryEntity WHERE id = :songId LIMIT 1")
|
|
suspend fun isSongPresentInHistory(songId: Int): HistoryEntity?
|
|
|
|
@Update
|
|
suspend fun updateHistorySong(historyEntity: HistoryEntity)
|
|
|
|
@Query("SELECT * FROM HistoryEntity ORDER BY time_played DESC LIMIT $HISTORY_LIMIT")
|
|
fun historySongs(): List<HistoryEntity>
|
|
|
|
@Query("SELECT * FROM HistoryEntity ORDER BY time_played DESC LIMIT $HISTORY_LIMIT")
|
|
fun observableHistorySongs(): LiveData<List<HistoryEntity>>
|
|
} |