WarmongerDao.kt 818 B

1234567891011121314151617181920212223242526272829303132
  1. package com.sirekanian.acf.data.local
  2. import androidx.room.Dao
  3. import androidx.room.Insert
  4. import androidx.room.Query
  5. import androidx.room.Transaction
  6. import kotlinx.coroutines.flow.Flow
  7. private const val LIMIT = 200
  8. @Dao
  9. interface WarmongerDao {
  10. @Query("SELECT * FROM WarmongerEntity ORDER BY cyrillicName LIMIT $LIMIT")
  11. fun observeAll(): Flow<List<WarmongerEntity>>
  12. @Query("SELECT * FROM WarmongerEntity WHERE WarmongerEntity MATCH :query LIMIT $LIMIT")
  13. fun observeByQuery(query: String): Flow<List<WarmongerEntity>>
  14. @Query("DELETE FROM WarmongerEntity")
  15. suspend fun deleteAll()
  16. @Insert
  17. suspend fun insertAll(users: List<WarmongerEntity>)
  18. @Transaction
  19. suspend fun deleteAndInsertAll(users: List<WarmongerEntity>) {
  20. deleteAll()
  21. insertAll(users)
  22. }
  23. }