This commit is contained in:
17
app/src/main/java/me/zobrist/tichucounter/data/DaoBase.kt
Normal file
17
app/src/main/java/me/zobrist/tichucounter/data/DaoBase.kt
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package me.zobrist.tichucounter.data
|
||||||
|
|
||||||
|
import androidx.room.*
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface DaoBase<T> {
|
||||||
|
|
||||||
|
@Insert
|
||||||
|
fun insert(entity: T): Long
|
||||||
|
|
||||||
|
@Update
|
||||||
|
fun update(entity: T)
|
||||||
|
|
||||||
|
@Delete
|
||||||
|
fun delete(entity: T)
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ import kotlinx.coroutines.flow.Flow
|
|||||||
|
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface GameDao {
|
interface GameDao: DaoBase<Game> {
|
||||||
|
|
||||||
@Query("SELECT * FROM game")
|
@Query("SELECT * FROM game")
|
||||||
fun getAll(): Flow<List<Game>>
|
fun getAll(): Flow<List<Game>>
|
||||||
@@ -22,12 +22,4 @@ interface GameDao {
|
|||||||
@Query("UPDATE game SET active = 0 WHERE uid is not :gameId;")
|
@Query("UPDATE game SET active = 0 WHERE uid is not :gameId;")
|
||||||
fun setOthersInactive(gameId: Long)
|
fun setOthersInactive(gameId: Long)
|
||||||
|
|
||||||
@Insert
|
|
||||||
fun insert(game: Game): Long
|
|
||||||
|
|
||||||
@Update
|
|
||||||
fun update(game: Game)
|
|
||||||
|
|
||||||
@Delete
|
|
||||||
fun delete(round: Game)
|
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ import androidx.room.Query
|
|||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface RoundDao {
|
interface RoundDao: DaoBase<Round> {
|
||||||
|
|
||||||
@Query("SELECT * FROM round")
|
@Query("SELECT * FROM round")
|
||||||
fun getAll(): Flow<List<Round>>
|
fun getAll(): Flow<List<Round>>
|
||||||
@@ -18,6 +18,4 @@ interface RoundDao {
|
|||||||
@Insert
|
@Insert
|
||||||
fun insertAll(vararg rounds: Round)
|
fun insertAll(vararg rounds: Round)
|
||||||
|
|
||||||
@Delete
|
|
||||||
fun delete(round: Round)
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user