-
Notifications
You must be signed in to change notification settings - Fork 1
/
AccountDao.kt
29 lines (23 loc) · 839 Bytes
/
AccountDao.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
package com.dluvian.voyage.data.room.dao
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Transaction
import com.dluvian.voyage.data.room.entity.AccountEntity
@Dao
interface AccountDao {
@Query("SELECT * FROM account LIMIT 1")
suspend fun getAccount(): AccountEntity?
@Query("SELECT packageName FROM account LIMIT 1")
suspend fun getPackageName(): String
@Transaction
suspend fun updateAccount(account: AccountEntity) {
internalDeleteAllAccounts()
internalInsertAccount(accountEntity = account)
}
@Query("DELETE FROM account")
suspend fun internalDeleteAllAccounts()
@Insert(onConflict = OnConflictStrategy.IGNORE)
suspend fun internalInsertAccount(accountEntity: AccountEntity)
}