Compare commits
No commits in common. 'master' and 'API_NextStep' have entirely different histories.
master
...
API_NextSt
Before Width: | Height: | Size: 89 KiB |
Before Width: | Height: | Size: 75 KiB |
Before Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 35 KiB |
@ -1,31 +0,0 @@
|
||||
package uca.iut.clermont.data
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
import uca.iut.clermont.data.dao.CompetitionDao
|
||||
import uca.iut.clermont.model.Competition
|
||||
|
||||
@Database(entities = arrayOf(Competition::class), version = 1)
|
||||
abstract class BDD : RoomDatabase() {
|
||||
|
||||
abstract fun competitionDao(): CompetitionDao
|
||||
|
||||
companion object {
|
||||
|
||||
private var INSTANCE: BDD? = null
|
||||
|
||||
fun getInstance(context: Context) =
|
||||
INSTANCE ?: synchronized(this) {
|
||||
val db = Room.databaseBuilder(
|
||||
context,
|
||||
BDD::class.java,
|
||||
"ScorItDB"
|
||||
).build()
|
||||
INSTANCE = db
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package uca.iut.clermont.data.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Delete
|
||||
import androidx.room.Insert
|
||||
import androidx.room.Query
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import uca.iut.clermont.model.Competition
|
||||
|
||||
@Dao
|
||||
interface CompetitionDao {
|
||||
|
||||
@Delete
|
||||
fun deleteCompetition(competition: Competition)
|
||||
|
||||
@Query("SELECT * FROM competition")
|
||||
fun getAllCompetitions(): Flow<List<Competition>>
|
||||
|
||||
@Insert
|
||||
fun insertCompetition(competition: Competition)
|
||||
|
||||
}
|
@ -1,16 +1,11 @@
|
||||
package uca.iut.clermont.model
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = "competitions")
|
||||
class Competition(
|
||||
@PrimaryKey val id: Int,
|
||||
@ColumnInfo val name: String,
|
||||
@ColumnInfo val code: String,
|
||||
@ColumnInfo val type: String,
|
||||
@ColumnInfo val emblem: String,
|
||||
@ColumnInfo val currentSeason: Season,
|
||||
val id: Int,
|
||||
val name: String,
|
||||
val code: String,
|
||||
val type: String,
|
||||
val emblem: String,
|
||||
val currentSeason: Season,
|
||||
val area: Area
|
||||
)
|
Loading…
Reference in new issue