package com.syncflow.data.db

import androidx.room.*
import com.syncflow.data.db.entities.CloudAccountEntity
import kotlinx.coroutines.flow.Flow

@Dao
interface CloudAccountDao {
    @Query("SELECT * FROM cloud_accounts ORDER BY displayName")
    fun observeAll(): Flow<List<CloudAccountEntity>>

    @Query("SELECT * FROM cloud_accounts")
    suspend fun getAll(): List<CloudAccountEntity>

    @Query("SELECT * FROM cloud_accounts WHERE id = :id")
    suspend fun getById(id: Long): CloudAccountEntity?

    @Insert(onConflict = OnConflictStrategy.ABORT)
    suspend fun insert(entity: CloudAccountEntity): Long

    @Update
    suspend fun update(entity: CloudAccountEntity)

    @Delete
    suspend fun delete(entity: CloudAccountEntity)
}
