Created Balance entity and BalanceDao to create the Balances db table with Room
This commit is contained in:
parent
e7d2719a4d
commit
c0d20e67bd
3 changed files with 30 additions and 0 deletions
|
@ -0,0 +1,17 @@
|
||||||
|
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.Balance
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface BalanceDao {
|
||||||
|
|
||||||
|
@Query("SELECT * FROM balances")
|
||||||
|
fun getAllBalances(): LiveData<List<Balance>>
|
||||||
|
|
||||||
|
@Insert
|
||||||
|
fun insert(balance: Balance)
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ import cy.agorise.bitsybitshareswallet.models.Asset
|
||||||
abstract class BitsyDatabase : RoomDatabase() {
|
abstract class BitsyDatabase : RoomDatabase() {
|
||||||
|
|
||||||
abstract fun assetDao(): AssetDao
|
abstract fun assetDao(): AssetDao
|
||||||
|
abstract fun balanceDao(): BalanceDao
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package cy.agorise.bitsybitshareswallet.models
|
||||||
|
|
||||||
|
import androidx.room.ColumnInfo
|
||||||
|
import androidx.room.Entity
|
||||||
|
|
||||||
|
@Entity(tableName = "balances", primaryKeys = ["user_id", "asset_id"])
|
||||||
|
data class Balance(
|
||||||
|
@ColumnInfo(name = "user_id") val userId: String,
|
||||||
|
@ColumnInfo(name = "asset_id") val assetId: String,
|
||||||
|
@ColumnInfo(name = "asset_amount") val assetAmount: Long,
|
||||||
|
@ColumnInfo(name = "last_update") val lastUpdate: Long
|
||||||
|
)
|
Loading…
Reference in a new issue