Avoid runBlocking
This commit is contained in:
@@ -12,6 +12,10 @@ data class ClientRecord(@PrimaryKey
|
||||
var macLookupPending: Boolean = true) {
|
||||
@androidx.room.Dao
|
||||
abstract class Dao {
|
||||
@Query("SELECT * FROM `ClientRecord` WHERE `mac` = :mac")
|
||||
protected abstract fun lookupBlocking(mac: Long): ClientRecord?
|
||||
fun lookupOrDefaultBlocking(mac: Long) = lookupBlocking(mac) ?: ClientRecord(mac)
|
||||
|
||||
@Query("SELECT * FROM `ClientRecord` WHERE `mac` = :mac")
|
||||
protected abstract suspend fun lookup(mac: Long): ClientRecord?
|
||||
suspend fun lookupOrDefault(mac: Long) = lookup(mac) ?: ClientRecord(mac)
|
||||
|
||||
@@ -41,8 +41,8 @@ data class TrafficRecord(
|
||||
@androidx.room.Dao
|
||||
abstract class Dao {
|
||||
@Insert
|
||||
protected abstract suspend fun insertInternal(value: TrafficRecord): Long
|
||||
suspend fun insert(value: TrafficRecord) {
|
||||
protected abstract fun insertInternal(value: TrafficRecord): Long
|
||||
fun insert(value: TrafficRecord) {
|
||||
check(value.id == null)
|
||||
value.id = insertInternal(value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user