mt_task_roomdb/app/src/main/java/world/whatever/task_roomdb/WordDao.kt
surtur a78c8d0148
finalise app
* add NewWordActivity
* Connect with the data
2021-12-03 02:57:14 +01:00

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()
}