package app.closer.data.local

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import app.closer.data.local.entity.DatePlanPreferenceEntity

@Dao
interface DatePlanPreferenceDao {
    @Query("SELECT * FROM date_plan_preferences WHERE id = :id LIMIT 1")
    suspend fun getById(id: String): DatePlanPreferenceEntity?

    @Query("SELECT * FROM date_plan_preferences WHERE couple_id = :coupleId ORDER BY updated_at DESC")
    suspend fun getByCoupleId(coupleId: String): List<DatePlanPreferenceEntity>

    @Query("SELECT * FROM date_plan_preferences WHERE couple_id = :coupleId AND date_idea_id = :dateIdeaId LIMIT 1")
    suspend fun getPreference(coupleId: String, dateIdeaId: String): DatePlanPreferenceEntity?

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(preference: DatePlanPreferenceEntity)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertAll(pREFERENCES: List<DatePlanPreferenceEntity>)

    @Delete
    suspend fun delete(preference: DatePlanPreferenceEntity)

    @Query("DELETE FROM date_plan_preferences WHERE couple_id = :coupleId")
    suspend fun deleteByCoupleId(coupleId: String)
}
