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: Long): HistoryEntity? @Update suspend fun updateHistorySong(historyEntity: HistoryEntity) @Query("SELECT * FROM HistoryEntity ORDER BY time_played DESC LIMIT $HISTORY_LIMIT") fun historySongs(): List @Query("SELECT * FROM HistoryEntity ORDER BY time_played DESC LIMIT $HISTORY_LIMIT") fun observableHistorySongs(): LiveData> }