package cz.muni.sutralog.database

import androidx.lifecycle.LiveData
import androidx.room.*

@Dao
interface CategoryDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun saveCategory(category: CategoryEntity): Long

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

    @Query("SELECT * FROM CategoryEntity")
    fun getAllCategories(): List<CategoryEntity>

    @Query("SELECT * FROM CategoryEntity WHERE id = :id")
    fun getCategoryById(id: Long): CategoryEntity

    @Query("SELECT * FROM CategoryEntity WHERE id = :id")
    fun getDeadCategoryById(id: Long): CategoryEntity

    @Query("DELETE FROM CategoryEntity WHERE id = :id")
    fun deleteCategoryById(id: Long)

    @Delete(entity = CategoryEntity::class)
    fun deleteCategory(category: CategoryEntity)
}
