mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 18:47:03 +05:30
feat(database): use Requery's repackaged SQLite for databases
This commit is contained in:
parent
558062a915
commit
3347224018
5 changed files with 18 additions and 4 deletions
|
@ -32,6 +32,7 @@ dependencies {
|
|||
implementation(libs.dagger)
|
||||
implementation(libs.sqldelight.androidDriver)
|
||||
implementation(libs.sqldelight.primitiveAdapters)
|
||||
implementation(libs.sqlite.android)
|
||||
|
||||
testImplementation(libs.sqldelight.jvmDriver)
|
||||
addTestDependencies(project)
|
||||
|
|
|
@ -18,6 +18,7 @@ import dev.msfjarvis.claw.database.LobstersDatabase
|
|||
import dev.msfjarvis.claw.database.local.PostComments
|
||||
import dev.msfjarvis.claw.database.local.SavedPost
|
||||
import dev.msfjarvis.claw.database.model.CSVAdapter
|
||||
import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory
|
||||
|
||||
@Module
|
||||
@ContributesTo(ApplicationScope::class)
|
||||
|
@ -27,11 +28,17 @@ object DatabaseModule {
|
|||
|
||||
@Provides
|
||||
fun provideDatabase(@ForScope(ApplicationScope::class) context: Context): LobstersDatabase {
|
||||
val driver = AndroidSqliteDriver(LobstersDatabase.Schema, context, LOBSTERS_DATABASE_NAME)
|
||||
val driver =
|
||||
AndroidSqliteDriver(
|
||||
schema = LobstersDatabase.Schema,
|
||||
context = context,
|
||||
name = LOBSTERS_DATABASE_NAME,
|
||||
factory = RequerySQLiteOpenHelperFactory(),
|
||||
)
|
||||
return LobstersDatabase(
|
||||
driver,
|
||||
PostComments.Adapter(CSVAdapter()),
|
||||
SavedPost.Adapter(IntColumnAdapter, CSVAdapter()),
|
||||
driver = driver,
|
||||
PostCommentsAdapter = PostComments.Adapter(CSVAdapter()),
|
||||
SavedPostAdapter = SavedPost.Adapter(IntColumnAdapter, CSVAdapter()),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue