30 lines
800 B
Kotlin
30 lines
800 B
Kotlin
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 cost ASC")
|
|
fun selectExpensesCost(): Flow<List<Expense>>
|
|
|
|
@Query("SELECT * FROM expense ORDER BY rate ASC")
|
|
fun selectExpensesRate(): Flow<List<Expense>>
|
|
|
|
} |