package cz.muni.sutralog.database

import androidx.room.*

@Dao
interface PhotoDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun savePhoto(photo: PhotoEntity): Long

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun savePhotos(photos: List<PhotoEntity>)

    @Query("SELECT * FROM PhotoEntity")
    fun getAllPhotos(): List<PhotoEntity>

    @Query("SELECT * FROM PhotoEntity WHERE rockId = :rockId")
    fun getPhotosByCategoryId(rockId: Long): List<PhotoEntity>

    @Query("SELECT * FROM PhotoEntity WHERE id = :id")
    fun getPhotoById(id: Long): PhotoEntity

    @Query("DELETE FROM PhotoEntity WHERE id = :id")
    fun deletePhotoById(id: Long)

    @Delete(entity = PhotoEntity::class)
    fun deletePhoto(photo: PhotoEntity)
}