package com.placeholder.sherpai2.data.local.model

import androidx.room.Embedded
import androidx.room.Junction
import androidx.room.Relation
import com.placeholder.sherpai2.data.local.entity.*

/**
 * ImageWithEverything - Fully hydrated image with ALL relationships
 *
 * Room loads this in ONE query using @Transaction!
 * NO N+1 problem - all tags and face tags loaded together
 *
 * Usage:
 * - ImageAggregateDao.observeAllImagesWithEverything()
 * - Search, Explore, Albums
 */
data class ImageWithEverything(
    @Embedded
    val image: ImageEntity,

    /**
     * Tags for this image (via image_tags join table)
     * Room automatically joins through ImageTagEntity
     */
    @Relation(
        parentColumn = "imageId",
        entityColumn = "tagId",
        associateBy = Junction(
            value = ImageTagEntity::class,
            parentColumn = "imageId",
            entityColumn = "tagId"
        )
    )
    val tags: List<TagEntity>,

    /**
     * Face tags for this image
     * Room automatically loads all PhotoFaceTagEntity for this imageId
     */
    @Relation(
        parentColumn = "imageId",
        entityColumn = "imageId"
    )
    val faceTags: List<PhotoFaceTagEntity>
)