package com.example.bnsptest.data.local.dao

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

@Dao
interface ProductDao {
    @Query("SELECT * FROM products")
    fun getAllProducts(): LiveData<List<Product>>

    @Query("SELECT COUNT(*) FROM products")
    suspend fun getProductCount(): Int

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertProducts(products: List<Product>)

    @Update
    suspend fun updateProduct(product: Product)

    @Query("UPDATE products SET isAddedToCart = 0, quantity = 0 WHERE isAddedToCart = 1")
    suspend fun clearCart()

    @Query("DELETE FROM products")
    suspend fun deleteAllProducts()
}
