package com.prodhack.moscow2025.data.data_providers.local_db.dao

import androidx.paging.PagingSource
import androidx.room.Dao
import androidx.room.Query
import androidx.room.Upsert
import com.prodhack.moscow2025.data.base.BasePaginationDAO
import com.prodhack.moscow2025.data.data_providers.local_db.entities.ResumeEntity
import kotlinx.coroutines.flow.Flow

@Dao
interface ResumeDao: BasePaginationDAO<ResumeEntity> {

	@Query("DELETE FROM resumes")
	override suspend fun clearAll()

	@Upsert
	override suspend fun upsertAll(data: List<ResumeEntity>)

	@Query("SELECT * FROM resumes")
	override fun getPaginatedData(): PagingSource<Int, ResumeEntity>

	@Query("SELECT * FROM resumes WHERE id = :resumeId LIMIT 1")
	fun getById(resumeId: String): Flow<ResumeEntity?>

	@Query("DELETE FROM resumes WHERE id = :resumeId")
	suspend fun deleteWithId(resumeId: String)
}
