Commit 59eac2eb authored by Joey's avatar Joey

data: glucose: add live getById

Signed-off-by: Joey's avatarJoey <bevilacquajoey@gmail.com>
Change-Id: I200d9cd244968d0d67999a26729f4f7aa441c32f
parent 1c063526
......@@ -32,8 +32,11 @@ interface GlucoseDao {
@get:Query("SELECT * FROM glucose ORDER BY date DESC LIMIT 1")
val last: LiveData<List<Glucose>>
@Query("SELECT * FROM glucose WHERE uid IN (:uids)")
suspend fun getById(vararg uids: Long): List<Glucose>
@Query("SELECT * FROM glucose WHERE uid IN (:uid) LIMIT 1")
fun getByIdLive(uid: Long): LiveData<List<Glucose>>
@Query("SELECT * FROM glucose WHERE uid IN (:uid) LIMIT 1")
suspend fun getById(uid: Long): List<Glucose>
@Query("SELECT * FROM glucose ORDER BY date DESC")
suspend fun getAllItems(): List<Glucose>
......
......@@ -24,6 +24,8 @@ class GlucoseRepository private constructor(private val dao: GlucoseDao) : BaseR
val last = dao.last
fun getByIdLive(uid: Long) = dao.getByIdLive(uid)
suspend fun getById(uid: Long) = withContext(IO) {
dao.getById(uid).firstOrNull() ?: Glucose()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment