Skip to content

Instantly share code, notes, and snippets.

@ubuntudroid
Created August 10, 2019 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ubuntudroid/162e554c689617cd65a97158a88019f8 to your computer and use it in GitHub Desktop.
Save ubuntudroid/162e554c689617cd65a97158a88019f8 to your computer and use it in GitHub Desktop.
@Entity(
foreignKeys = [
ForeignKey(
entity = Color::class,
parentColumns = ["id"],
childColumns = ["color_id"],
onDelete = ForeignKey.CASCADE, // or any other strategy
onUpdate = ForeignKey.CASCADE, // or any other strategy
// deferred = true
)
]
)
data class Car(
@PrimaryKey val id: String,
@ColumnInfo(name = "program_id", index = true) val colorId: String
)
@Entity
data class Color(
@PrimaryKey val id: String,
val name: String,
val hex: String
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment