package com.example.firstapp.database.dao
|
|
import androidx.room.Dao
|
import androidx.room.Delete
|
import androidx.room.Insert
|
import androidx.room.Query
|
import androidx.room.Update
|
import com.example.firstapp.database.entity.Code
|
import com.example.firstapp.database.entity.Msg
|
import io.reactivex.Completable
|
|
@Dao
|
interface CodeDao {
|
|
@Insert
|
fun insert(code: Code): Long
|
|
@Update
|
fun update(code: Code)
|
|
@Delete
|
fun delete(msg: Msg): Completable
|
|
@Query("DELETE FROM Code where id=:id")
|
fun delete(id: Long)
|
|
|
@Query("SELECT * FROM Code WHERE id = :id LIMIT 1")
|
fun getCodeById(id: Long): Code?
|
|
@Query("SELECT * FROM Code")
|
fun getAllCodes(): List<Code>
|
|
@Query("SELECT * FROM Code WHERE type = :type")
|
fun getCodesByType(type: String): List<Code>
|
|
|
|
@Query("DELETE FROM Code WHERE id = :id")
|
fun deleteCodeById(id: Long)
|
|
@Query("SELECT * FROM Code order by time desc")
|
abstract fun getAllCodesDesc(): List<Code>
|
}
|