package app.closer.data.local

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import app.closer.data.local.entity.CategoryEntity

@Dao
interface CategoryDao {
    @Query("SELECT * FROM question_category ORDER BY display_name ASC")
    suspend fun getAllCategories(): List<CategoryEntity>

    @Query("SELECT * FROM question_category WHERE id = :id LIMIT 1")
    suspend fun getCategoryById(id: String): CategoryEntity?

    @Query("SELECT * FROM question_category WHERE access = :access")
    suspend fun getCategoriesByAccess(access: String): List<CategoryEntity>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(category: CategoryEntity)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertAll(categories: List<CategoryEntity>)

    @Delete
    suspend fun delete(category: CategoryEntity)
}
