Created Authority entity and AuthoritiyDao to create the Authorities db table with Room
This commit is contained in:
parent
e835e7de89
commit
72e39368aa
3 changed files with 43 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.Authority
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface AuthorityDao {
|
||||||
|
|
||||||
|
@Query("SELECT * FROM authorities")
|
||||||
|
fun getAllAuthorities(): LiveData<List<Authority>>
|
||||||
|
|
||||||
|
@Insert
|
||||||
|
fun insert(authority: Authority)
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ abstract class BitsyDatabase : RoomDatabase() {
|
||||||
abstract fun assetDao(): AssetDao
|
abstract fun assetDao(): AssetDao
|
||||||
abstract fun balanceDao(): BalanceDao
|
abstract fun balanceDao(): BalanceDao
|
||||||
abstract fun userAccountDao(): UserAccountDao
|
abstract fun userAccountDao(): UserAccountDao
|
||||||
|
abstract fun authorityDao(): AuthorityDao
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package cy.agorise.bitsybitshareswallet.models
|
||||||
|
|
||||||
|
import androidx.room.ColumnInfo
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.ForeignKey
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
|
|
||||||
|
@Entity(tableName = "authorities", foreignKeys =
|
||||||
|
[ForeignKey(
|
||||||
|
entity = UserAccount::class,
|
||||||
|
parentColumns = ["id"],
|
||||||
|
childColumns = ["user_id"],
|
||||||
|
onUpdate = ForeignKey.CASCADE,
|
||||||
|
onDelete = ForeignKey.CASCADE
|
||||||
|
)]
|
||||||
|
)
|
||||||
|
data class Authority (
|
||||||
|
@PrimaryKey(autoGenerate = true)
|
||||||
|
@ColumnInfo(name = "id") val id: Long,
|
||||||
|
@ColumnInfo(name = "encrypted_brainkey") val encryptedBrainkey: String,
|
||||||
|
@ColumnInfo(name = "encrypted_sequence_number") val encryptedSequenceNumber: String, // TODO verify data type
|
||||||
|
@ColumnInfo(name = "encrypted_wif") val encryptedWif: String,
|
||||||
|
@ColumnInfo(name = "user_id") val userId: String,
|
||||||
|
@ColumnInfo(name = "authority_type") val authorityType: Int
|
||||||
|
)
|
Loading…
Reference in a new issue