EntrepriseDao.kt 24 lignes · 765 octets
package fr.ebii.card2vcf.data

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query

@Dao
interface EntrepriseDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun upsert(entity: EntrepriseEntity): Long

    @Query("SELECT * FROM entreprises WHERE serverId = :serverId")
    suspend fun getByServerId(serverId: String): EntrepriseEntity?

    @Query("SELECT * FROM entreprises WHERE localId = :localId")
    suspend fun getByLocalId(localId: Long): EntrepriseEntity?

    @Query("DELETE FROM entreprises WHERE serverId = :serverId")
    suspend fun deleteByServerId(serverId: String)

    @Query("SELECT * FROM entreprises")
    suspend fun listAll(): List<EntrepriseEntity>
}