package com.fabledsword.minstrel.cache.db.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.fabledsword.minstrel.cache.db.entities.CachedResumeStateEntity
import kotlinx.coroutines.flow.Flow

@Dao
interface CachedResumeStateDao {
    @Query("SELECT * FROM cached_resume_state WHERE id = 1")
    suspend fun get(): CachedResumeStateEntity?

    @Query("SELECT * FROM cached_resume_state WHERE id = 1")
    fun observe(): Flow<CachedResumeStateEntity?>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun upsert(row: CachedResumeStateEntity)

    @Query("DELETE FROM cached_resume_state")
    suspend fun clear()
}
