InteractionDao.kt
38 lignes · 1380 octets
package fr.ebii.card2vcf.data import androidx.room.Dao import androidx.room.Insert import androidx.room.OnConflictStrategy import androidx.room.Query import androidx.room.Update import kotlinx.coroutines.flow.Flow @Dao interface InteractionDao { @Insert(onConflict = OnConflictStrategy.REPLACE) suspend fun upsert(entity: InteractionEntity): Long @Update suspend fun update(entity: InteractionEntity) @Query("SELECT * FROM interactions WHERE localId = :localId") suspend fun getByLocalId(localId: Long): InteractionEntity? @Query("SELECT * FROM interactions WHERE serverId = :serverId") suspend fun getByServerId(serverId: String): InteractionEntity? @Query("DELETE FROM interactions WHERE serverId = :serverId") suspend fun deleteByServerId(serverId: String) @Query("DELETE FROM interactions WHERE localId = :localId") suspend fun deleteByLocalId(localId: Long) @Query("SELECT * FROM interactions WHERE contactServerId = :contactServerId") suspend fun listByContactServerId(contactServerId: String): List<InteractionEntity> @Query("SELECT * FROM interactions WHERE contactServerId = :contactServerId ORDER BY createdAt DESC") fun observeByContactServerId(contactServerId: String): Flow<List<InteractionEntity>> @Query("SELECT * FROM interactions") suspend fun listAll(): List<InteractionEntity> }
GitRust