package keijumt.todoapp.di import android.app.Application import android.arch.persistence.room.Room import dagger.Module import dagger.Provides import keijumt.todoapp.data.db.AppDatabase import keijumt.todoapp.data.db.TaskDatabase import keijumt.todoapp.data.db.TaskRoomDatabase import keijumt.todoapp.data.db.dao.TaskDao import javax.inject.Singleton /** * * Created by matsumoto_k on 2018/03/09. */ @Module class DatabaseModule { @Singleton @Provides fun provideTaskDatabase(db: AppDatabase, dao: TaskDao): TaskDatabase = TaskRoomDatabase(db, dao) @Singleton @Provides fun provideDb(app: Application): AppDatabase = Room.databaseBuilder(app, AppDatabase::class.java, "toDoApp.db") .fallbackToDestructiveMigration() .build() @Singleton @Provides fun provideTaskDao(db: AppDatabase): TaskDao = db.taskDao() }