Create DAO file.
This commit is contained in:
parent
845715122f
commit
d8ecd7b621
30
app/src/main/java/com/hyperling/expensetracker/ExpenseDao.kt
Normal file
30
app/src/main/java/com/hyperling/expensetracker/ExpenseDao.kt
Normal file
@ -0,0 +1,30 @@
|
||||
package com.hyperling.expensetracker
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Delete
|
||||
import androidx.room.Query
|
||||
import androidx.room.Upsert
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface ExpenseDao {
|
||||
|
||||
// 2024-12-28
|
||||
// If these complain about return type errors, try upgrading
|
||||
// the ROOM version, otherwise remove the SUSPEND keyword.
|
||||
@Upsert
|
||||
suspend fun upsertExpense(expense: Expense)
|
||||
|
||||
@Delete
|
||||
suspend fun deleteExpense(expense: Expense)
|
||||
|
||||
@Query("SELECT * FROM expense ORDER BY name ASC")
|
||||
fun selectExpensesName(): Flow<List<Expense>>
|
||||
|
||||
@Query("SELECT * FROM expense ORDER BY rate ASC")
|
||||
fun selectExpensesRate(): Flow<List<Expense>>
|
||||
|
||||
@Query("SELECT * FROM expense ORDER BY cost ASC")
|
||||
fun selectExpensesCost(): Flow<List<Expense>>
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user