package llc.arma.ble.app.framework.di

import android.app.Application
import androidx.room.Room
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import llc.arma.ble.data.db.AppDatabase
import llc.arma.ble.data.db.BleNameDao
import llc.arma.ble.data.db.RotationsDao
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
class DatabaseModule {

    @Provides
    @Singleton
    fun provideDatabase(app: Application): AppDatabase {
        return Room.databaseBuilder(app, AppDatabase::class.java, "app-database").build()
    }

    @Provides
    @Singleton
    fun provideRotationsDao(db: AppDatabase): RotationsDao {
        return db.getRotationsDao()
    }

    @Provides
    @Singleton
    fun provideBleNamesDao(db: AppDatabase): BleNameDao {
        return db.getBleNamesDao()
    }

}