package com.gestoreasy.database.dao

import androidx.room.*
import com.gestoreasy.database.entities.CheckIn
import kotlinx.coroutines.flow.Flow

@Dao
interface CheckInDao {
    @Insert
    suspend fun insert(checkIn: CheckIn): Long
    
    @Query("SELECT * FROM checkins WHERE client_id = :clientId ORDER BY created_at DESC")
    suspend fun getByClient(clientId: Long): List<CheckIn>
    
    @Query("SELECT * FROM checkins WHERE synced = 0 ORDER BY created_at ASC")
    suspend fun getPendingSync(): List<CheckIn>
    
    @Query("UPDATE checkins SET synced = 1 WHERE id = :id")
    suspend fun markAsSynced(id: Long)
    
    @Query("SELECT * FROM checkins ORDER BY created_at DESC")
    fun getAllFlow(): Flow<List<CheckIn>>
}

