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 MessageSummaryDao {

    @Query("select * from MessageSummary order by last_update desc")
    fun getAll(): LiveData<List<MessageSummary>>

    @Query("select * from MessageSummary where l_pin = :pin")
    fun get(pin: String): LiveData<List<MessageSummary>>

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

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

}