Create DAO file.

This commit is contained in:
Hyperling 2025-01-09 14:10:38 -07:00
parent 845715122f
commit d8ecd7b621

View 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>>
}