23 lines
574 B
Kotlin
23 lines
574 B
Kotlin
package world.whatever.task_roomdb
|
|
|
|
import androidx.room.Dao
|
|
import androidx.room.Insert
|
|
import androidx.room.OnConflictStrategy
|
|
import androidx.room.Query
|
|
import kotlinx.coroutines.flow.Flow
|
|
|
|
@Dao
|
|
interface WordDao {
|
|
|
|
// The flow always holds/caches latest version of data. Notifies its observers when the
|
|
// data has changed.
|
|
@Query("SELECT * FROM word_table ORDER BY word ASC")
|
|
fun getAlphabetizedWords(): Flow<List<Word>>
|
|
|
|
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
|
suspend fun insert(word: Word)
|
|
|
|
@Query("DELETE FROM word_table")
|
|
suspend fun deleteAll()
|
|
}
|