cloudroam
2025-02-28 1097c45d8d6aa4b74a50e8d9a99dedab73f2bbad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.example.firstapp.database.dao
 
 
import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.RawQuery
import androidx.room.Update
import androidx.sqlite.db.SupportSQLiteQuery
import com.example.firstapp.database.entity.Msg
 
import io.reactivex.Completable
import io.reactivex.Single
 
@Dao
interface MsgDao {
 
    @Insert(onConflict = OnConflictStrategy.IGNORE)
    fun insert(msg: Msg): Long
 
    @Delete
    fun delete(msg: Msg): Completable
 
    @Query("DELETE FROM Msg where id=:id")
    fun delete(id: Long)
 
    @RawQuery
    fun deleteAll(sql: SupportSQLiteQuery): Int
 
    @Query("DELETE FROM Msg")
    fun deleteAll()
 
    @Query("DELETE FROM Msg where time<:time")
    fun deleteTimeAgo(time: Long)
 
    @Update
    fun update(msg: Msg): Completable
 
    @Query("SELECT * FROM Msg where id=:id")
    fun get(id: Long): Single<Msg>
 
    @Query("SELECT count(*) FROM Msg where type=:type")
    fun count(type: String): Single<Int>
 
//    @Transaction
//    @Query("SELECT * FROM Msg WHERE type = :type ORDER BY id DESC")
//    fun pagingSource(type: String): PagingSource<Int, MsgAndLogs>
//
//    @Transaction
//    @RawQuery(observedEntities = [MsgAndLogs::class])
//    fun pagingSource(query: SupportSQLiteQuery): PagingSource<Int, MsgAndLogs>
 
}