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.CachedHistorySnapshotEntity
import kotlinx.coroutines.flow.Flow

@Dao
interface CachedHistorySnapshotDao {
    /** Observes the single snapshot row (null until the first fetch lands). */
    @Query("SELECT * FROM cached_history_snapshot WHERE id = 1")
    fun observe(): Flow<CachedHistorySnapshotEntity?>

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