-
Notifications
You must be signed in to change notification settings - Fork 3
/
PoiAddressDao.kt
43 lines (32 loc) · 1.38 KB
/
PoiAddressDao.kt
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
package me.zipi.navitotesla.db
import androidx.lifecycle.LiveData
import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
@Dao
interface PoiAddressDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertPoi(poi: PoiAddressEntity)
@Update(onConflict = OnConflictStrategy.REPLACE)
fun updatePoi(poi: PoiAddressEntity)
@Query("SELECT * FROM poi_address WHERE poi = :poi LIMIT 1")
fun findPoi(poi: String): LiveData<PoiAddressEntity>
@Query("SELECT * FROM poi_address WHERE poi = :poi LIMIT 1")
fun findPoiSync(poi: String): PoiAddressEntity?
@Query("SELECT * FROM poi_address WHERE created < :date AND (registered IS NULL OR registered = 0)")
fun findExpired(date: Long): List<PoiAddressEntity>
@Query("SELECT * FROM poi_address WHERE registered IS NULL OR registered = 0 ORDER BY created desc LIMIT :limit")
fun findRecentPoiSync(limit: Int): List<PoiAddressEntity>
@Query("SELECT * FROM poi_address WHERE registered = 1 ORDER BY poi")
fun findRegisteredPoiSync(): List<PoiAddressEntity>
@Delete
fun delete(poiAddressEntity: PoiAddressEntity)
@Query("DELETE FROM poi_address")
@Deprecated("")
fun deleteAll()
@Query("DELETE FROM poi_address WHERE registered = 0")
fun deleteAllNotRegistered()
}