package de.krisenvorrat.app.data.db.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import de.krisenvorrat.app.data.db.entity.PendingSyncOpEntity

@Dao
internal interface PendingSyncOpDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(op: PendingSyncOpEntity)

    @Query("SELECT * FROM pending_sync_ops ORDER BY created_at ASC")
    suspend fun getAll(): List<PendingSyncOpEntity>

    @Query("DELETE FROM pending_sync_ops WHERE id = :id")
    suspend fun deleteById(id: String)

    @Query("DELETE FROM pending_sync_ops WHERE item_id = :itemId")
    suspend fun deleteByItemId(itemId: String)
}
