package io.nexilis.service.data.daos

import androidx.lifecycle.LiveData
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import io.nexilis.service.data.entities.*

@Dao
interface OutgoingDao {

    @Query("select * from Outgoing")
    fun getAll(): LiveData<List<Outgoing>>

    @Query("select * from Outgoing where id = :id or package_id = :id")
    fun get(id: String): LiveData<List<Outgoing>>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(entity: Outgoing)

    @Query("delete from Outgoing")
    suspend fun deleteAll()

    @Query("delete from Outgoing where id = :id")
    suspend fun deleteId(id: String)

    @Query("delete from Outgoing where package_id = :id")
    suspend fun deletePackageId(id: String)

}