package com.syaroful.agrilinkvocpro.plant_disease_detection_feature.data.local.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.syaroful.agrilinkvocpro.plant_disease_detection_feature.data.local.entity.PlantDiagnosisEntity
import kotlinx.coroutines.flow.Flow

@Dao
interface PlantDiagnosisDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertDiagnosis(diagnosis: PlantDiagnosisEntity)

    @Query("SELECT * FROM plant_diagnosis ORDER BY timestamp DESC")
    fun getAllDiagnosis(): Flow<List<PlantDiagnosisEntity>>

    @Query("SELECT * FROM plant_diagnosis WHERE id = :id")
    fun getDiagnosisById(id: Int): Flow<PlantDiagnosisEntity?>
}