Вроде бы сделал связь, ура победа
This commit is contained in:
parent
d9cb297f65
commit
3e68677d23
@ -1,9 +1,14 @@
|
||||
package com.example.labwork.models
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = "bicycles")
|
||||
@Entity(tableName = "bicycles",
|
||||
foreignKeys = [ForeignKey(entity = User::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["userId"],
|
||||
onDelete = ForeignKey.SET_NULL)])
|
||||
data class Bicycle(
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
val id: Int?,
|
||||
|
@ -1,13 +0,0 @@
|
||||
package com.example.labwork.models
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Relation
|
||||
|
||||
data class UserWithBicycles(
|
||||
@Embedded val user: User,
|
||||
@Relation(
|
||||
parentColumn = "id",
|
||||
entityColumn = "userId"
|
||||
)
|
||||
val bicycles: List<Bicycle>
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user