Add missing DAOs (Data Access Object) to use with the Room database.
This commit is contained in:
parent
eed3407b7d
commit
73afded9bd
10 changed files with 59 additions and 13 deletions
|
@ -8,7 +8,6 @@ import cy.agorise.bitsybitshareswallet.models.Asset
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface AssetDao {
|
interface AssetDao {
|
||||||
|
|
||||||
@Insert
|
@Insert
|
||||||
fun insert(asset: Asset)
|
fun insert(asset: Asset)
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import cy.agorise.bitsybitshareswallet.models.Authority
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface AuthorityDao {
|
interface AuthorityDao {
|
||||||
|
|
||||||
@Insert
|
@Insert
|
||||||
fun insert(authority: Authority)
|
fun insert(authority: Authority)
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import cy.agorise.bitsybitshareswallet.models.Balance
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface BalanceDao {
|
interface BalanceDao {
|
||||||
|
|
||||||
@Insert
|
@Insert
|
||||||
fun insert(balance: Balance)
|
fun insert(balance: Balance)
|
||||||
|
|
||||||
|
|
|
@ -8,23 +8,26 @@ import cy.agorise.bitsybitshareswallet.models.*
|
||||||
|
|
||||||
@Database(entities = [
|
@Database(entities = [
|
||||||
Asset::class,
|
Asset::class,
|
||||||
Balance::class,
|
|
||||||
UserAccount::class,
|
|
||||||
Authority::class,
|
Authority::class,
|
||||||
UserAccountAuthority::class,
|
Balance::class,
|
||||||
BrainKey::class,
|
BrainKey::class,
|
||||||
EquivalentValue::class,
|
EquivalentValue::class,
|
||||||
Operation::class,
|
Operation::class,
|
||||||
Transfer::class
|
Transfer::class,
|
||||||
|
UserAccount::class,
|
||||||
|
UserAccountAuthority::class
|
||||||
], version = 1, exportSchema = false)
|
], version = 1, exportSchema = false)
|
||||||
abstract class BitsyDatabase : RoomDatabase() {
|
abstract class BitsyDatabase : RoomDatabase() {
|
||||||
|
|
||||||
abstract fun assetDao(): AssetDao
|
abstract fun assetDao(): AssetDao
|
||||||
abstract fun balanceDao(): BalanceDao
|
|
||||||
abstract fun userAccountDao(): UserAccountDao
|
|
||||||
abstract fun authorityDao(): AuthorityDao
|
abstract fun authorityDao(): AuthorityDao
|
||||||
abstract fun userAccountAuthorityDao(): UserAccountAuthorityDao
|
abstract fun balanceDao(): BalanceDao
|
||||||
abstract fun brainKeyDao(): BrainKeyDao
|
abstract fun brainKeyDao(): BrainKeyDao
|
||||||
|
abstract fun equivalentValueDao(): EquivalentValueDao
|
||||||
|
abstract fun operationDao(): OperationDao
|
||||||
|
abstract fun transferDao(): TransferDao
|
||||||
|
abstract fun userAccountDao(): UserAccountDao
|
||||||
|
abstract fun userAccountAuthorityDao(): UserAccountAuthorityDao
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package cy.agorise.bitsybitshareswallet.daos
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Insert
|
||||||
|
import androidx.room.Query
|
||||||
|
import cy.agorise.bitsybitshareswallet.models.EquivalentValue
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface EquivalentValueDao {
|
||||||
|
@Insert
|
||||||
|
fun insert(equivalentValue: EquivalentValue)
|
||||||
|
|
||||||
|
@Query("SELECT * FROM equivalent_values")
|
||||||
|
fun getAllEquivalentValues(): LiveData<List<EquivalentValue>>
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package cy.agorise.bitsybitshareswallet.daos
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Insert
|
||||||
|
import androidx.room.Query
|
||||||
|
import cy.agorise.bitsybitshareswallet.models.Operation
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface OperationDao {
|
||||||
|
@Insert
|
||||||
|
fun insert(operation: Operation)
|
||||||
|
|
||||||
|
@Query("SELECT * FROM operations")
|
||||||
|
fun getAllOperations(): LiveData<List<Operation>>
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package cy.agorise.bitsybitshareswallet.daos
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Insert
|
||||||
|
import androidx.room.Query
|
||||||
|
import cy.agorise.bitsybitshareswallet.models.Transfer
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface TransferDao {
|
||||||
|
@Insert
|
||||||
|
fun insert(transfer: Transfer)
|
||||||
|
|
||||||
|
@Query("SELECT * FROM transfers")
|
||||||
|
fun getAllTransfers(): LiveData<List<Transfer>>
|
||||||
|
}
|
|
@ -8,7 +8,6 @@ import cy.agorise.bitsybitshareswallet.models.Authority
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface UserAccountAuthorityDao {
|
interface UserAccountAuthorityDao {
|
||||||
|
|
||||||
@Insert
|
@Insert
|
||||||
fun insert(userAccountAuthorityDao: UserAccountAuthorityDao)
|
fun insert(userAccountAuthorityDao: UserAccountAuthorityDao)
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import cy.agorise.bitsybitshareswallet.models.UserAccount
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface UserAccountDao {
|
interface UserAccountDao {
|
||||||
|
|
||||||
@Insert
|
@Insert
|
||||||
fun insert(userAccount: UserAccount)
|
fun insert(userAccount: UserAccount)
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import androidx.room.ColumnInfo
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
|
|
||||||
@Entity(tableName = "balances", primaryKeys = ["user_account_id", "asset_id"])
|
@Entity(tableName = "balances", primaryKeys = ["user_account_id", "asset_id"])
|
||||||
// TODO verify if we can add user_account_id as primary key
|
// TODO make userAccountId and assetId be ForeignKeys
|
||||||
data class Balance(
|
data class Balance(
|
||||||
@ColumnInfo(name = "user_account_id") val userAccountId: String,
|
@ColumnInfo(name = "user_account_id") val userAccountId: String,
|
||||||
@ColumnInfo(name = "asset_id") val assetId: String,
|
@ColumnInfo(name = "asset_id") val assetId: String,
|
||||||
|
|
Loading…
Reference in a new issue