package cz.muni.sutralog.database

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

@Dao
interface CategoryDao {

    @Insert(onConflict = OnConflictStrategy.IGNORE)
    fun insertCategory(category: CategoryEntity): Long

    @Insert(onConflict = OnConflictStrategy.IGNORE)
    fun insertCategories(categories: List<CategoryEntity>)

    @Update
    fun updateCategory(category: CategoryEntity): Int

    @Update
    fun updateCategories(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)
}
