30 lines
867 B
Kotlin
Raw Normal View History

2026-06-09 16:27:40 +07:00
package com.longnh15.heimdall.di
import android.content.Context
import androidx.room.Room
import com.longnh15.heimdall.data.source.local.CredentialDao
import com.longnh15.heimdall.data.source.local.HeimdallDatabase
import com.longnh15.heimdall.data.source.local.LocalDataSource
import org.koin.core.annotation.Module
import org.koin.core.annotation.Single
@Module
class DatabaseModule {
@Single
fun provideDatabase(context: Context): HeimdallDatabase =
Room.databaseBuilder(
context,
HeimdallDatabase::class.java,
"heimdall.db"
).build()
@Single
fun provideCredentialDao(db: HeimdallDatabase): CredentialDao {
return db.credentialDao()
}
@Single
fun provideLocalDataSource(credentialDao: CredentialDao): LocalDataSource {
return LocalDataSource(credentialDao)
}
}