Magisk/app/src/main/java/com/topjohnwu/magisk/di/DatabaseModule.kt

21 lines
580 B
Kotlin
Raw Normal View History

package com.topjohnwu.magisk.di
import android.content.Context
import androidx.room.Room
import com.topjohnwu.magisk.data.database.*
import org.koin.dsl.module
val databaseModule = module {
single { createDatabase(get()) }
single { LogDao() }
single { PolicyDao(get()) }
single { SettingsDao() }
2019-05-10 17:13:15 +00:00
single { StringDao() }
single { createRepositoryDao(get()) }
}
fun createDatabase(context: Context): AppDatabase =
Room.databaseBuilder(context, AppDatabase::class.java, AppDatabase.NAME).build()
fun createRepositoryDao(db: AppDatabase) = db.repoDao()