package com.pixelized.biblib.database.relation

import androidx.room.Embedded
import androidx.room.Junction
import androidx.room.Relation
import com.pixelized.biblib.database.crossref.BookAuthorCrossRef
import com.pixelized.biblib.database.crossref.BookGenreCrossRef
import com.pixelized.biblib.database.data.*

data class BookRelation(
    @Embedded
    val book: BookDbo,
    @Relation(
        parentColumn = BookDbo.ID,
        entityColumn = AuthorDbo.ID,
        associateBy = Junction(BookAuthorCrossRef::class)
    )
    val authors: List<AuthorDbo>,
    @Relation(
        parentColumn = BookDbo.ID,
        entityColumn = GenreDbo.ID,
        associateBy = Junction(BookGenreCrossRef::class)
    )
    val genres: List<GenreDbo>?,
    @Relation(
        parentColumn = BookDbo.LANGUAGE_ID,
        entityColumn = LanguageDbo.ID
    )
    val language: LanguageDbo?,
    @Relation(
        parentColumn = BookDbo.SERIES_ID,
        entityColumn = SeriesDbo.ID
    )
    val series: SeriesDbo?,
)