package com.rssuper.database.entities

import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey
import java.util.Date

@Entity(
    tableName = "feed_items",
    foreignKeys = [
        ForeignKey(
            entity = SubscriptionEntity::class,
            parentColumns = ["id"],
            childColumns = ["subscriptionId"],
            onDelete = ForeignKey.CASCADE
        )
    ],
    indices = [
        Index(value = ["subscriptionId"]),
        Index(value = ["published"])
    ]
)
data class FeedItemEntity(
    @PrimaryKey
    val id: String,
    
    val subscriptionId: String,
    
    val title: String,
    
    val link: String? = null,
    
    val description: String? = null,
    
    val content: String? = null,
    
    val author: String? = null,
    
    val published: Date? = null,
    
    val updated: Date? = null,
    
    val categories: String? = null,
    
    val enclosureUrl: String? = null,
    
    val enclosureType: String? = null,
    
    val enclosureLength: Long? = null,
    
    val guid: String? = null,
    
    val isRead: Boolean = false,
    
    val isStarred: Boolean = false
)
