package de.krisenvorrat.app.data.db.dao

import androidx.room.Dao
import androidx.room.Query
import androidx.room.Upsert
import de.krisenvorrat.app.data.db.entity.SettingsEntity
import kotlinx.coroutines.flow.Flow

@Dao
internal interface SettingsDao {

    @Upsert
    suspend fun upsert(setting: SettingsEntity)

    @Query("SELECT value FROM settings WHERE `key` = :key")
    suspend fun getValue(key: String): String?

    @Query("SELECT value FROM settings WHERE `key` = :key")
    fun observeValue(key: String): Flow<String?>

    @Query("SELECT * FROM settings")
    fun getAll(): Flow<List<SettingsEntity>>

    @Upsert
    suspend fun upsertAll(settings: List<SettingsEntity>)
}
