Skip to content

Commit

Permalink
[feat] #4 di room
Browse files Browse the repository at this point in the history
  • Loading branch information
Sangwook123 committed Apr 13, 2024
1 parent e8af121 commit e3b561f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions core/database/src/main/java/org/sopt/database/di/DBModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.sopt.database.di

import android.content.Context
import androidx.room.Room
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import org.sopt.database.SoptDataBase
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object DBModule {
@Singleton
@Provides
fun providesDataBase(
@ApplicationContext context: Context
): SoptDataBase = Room.databaseBuilder(context, SoptDataBase::class.java, "sopt.db").build()

@Singleton
@Provides
fun providesDao(
soptDataBase: SoptDataBase
) = soptDataBase.soptDao()
}

0 comments on commit e3b561f

Please sign in to comment.