package melody.offline.music.database

import androidx.room.*
import melody.offline.music.bean.FavoriteBean

@Dao
interface FavoriteDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertFavoriteBean(bean: FavoriteBean)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertFavoriteBeans(beans: List<FavoriteBean>)

    @Query("SELECT * FROM FavoriteBean")
    suspend fun getAllFavoriteBeans(): List<FavoriteBean>

    @Delete
    suspend fun deleteFavoriteBean(bean: FavoriteBean)

    @Query("DELETE FROM FavoriteBean")
    suspend fun deleteAllFavoriteBean()

    @Update
    suspend fun updateFavoriteBean(bean: FavoriteBean)

    @Query("SELECT * FROM FavoriteBean WHERE videoId = :id LIMIT 1")
    suspend fun getFavoriteBeanByID(id: String): FavoriteBean?

}
