package com.example.tabbuy.data.local.dao

import androidx.lifecycle.LiveData
import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.example.tabbuy.data.local.entity.ProdukEntity

@Dao
interface ProdukDao {

    @Query("SELECT * FROM produk ORDER BY id DESC")
    fun getAllProduk(): LiveData<List<ProdukEntity>>

    @Query("SELECT * FROM produk WHERE nama LIKE :searchQuery OR deskripsi LIKE :searchQuery")
    fun searchProduk(searchQuery: String): LiveData<List<ProdukEntity>>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(produk: ProdukEntity)

    @Update
    suspend fun update(produk: ProdukEntity)

    @Delete
    suspend fun delete(produk: ProdukEntity)

}