Extract DaoBase
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-12-28 15:56:05 +01:00
parent bdb4410638
commit bdc9b64c63
3 changed files with 19 additions and 12 deletions

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

View File

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

View File

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