|
|
|
|
@ -16,39 +16,10 @@
|
|
|
|
|
|
|
|
|
|
package com.google.samples.apps.nowinandroid.core.database.model
|
|
|
|
|
|
|
|
|
|
import androidx.room.ColumnInfo
|
|
|
|
|
import androidx.room.Entity
|
|
|
|
|
import androidx.room.ForeignKey
|
|
|
|
|
import androidx.room.Index
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Cross reference for many to many relationship between [NewsResourceEntity] and [TopicEntity]
|
|
|
|
|
*/
|
|
|
|
|
@Entity(
|
|
|
|
|
tableName = "news_resources_topics",
|
|
|
|
|
primaryKeys = ["news_resource_id", "topic_id"],
|
|
|
|
|
foreignKeys = [
|
|
|
|
|
ForeignKey(
|
|
|
|
|
entity = NewsResourceEntity::class,
|
|
|
|
|
parentColumns = ["id"],
|
|
|
|
|
childColumns = ["news_resource_id"],
|
|
|
|
|
onDelete = ForeignKey.CASCADE,
|
|
|
|
|
),
|
|
|
|
|
ForeignKey(
|
|
|
|
|
entity = TopicEntity::class,
|
|
|
|
|
parentColumns = ["id"],
|
|
|
|
|
childColumns = ["topic_id"],
|
|
|
|
|
onDelete = ForeignKey.CASCADE,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
indices = [
|
|
|
|
|
Index(value = ["news_resource_id"]),
|
|
|
|
|
Index(value = ["topic_id"]),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
data class NewsResourceTopicCrossRef(
|
|
|
|
|
@ColumnInfo(name = "news_resource_id")
|
|
|
|
|
val newsResourceId: String,
|
|
|
|
|
@ColumnInfo(name = "topic_id")
|
|
|
|
|
val topicId: String,
|
|
|
|
|
)
|
|
|
|
|
|