cashapp / sqldelight

SQLDelight - Generates typesafe Kotlin APIs from SQL
https://cashapp.github.io/sqldelight/
Apache License 2.0
6.12k stars 512 forks source link

How use SQLDelight + IceRock MOKO(Widgets-Templates) library #1692

Closed Diy2210 closed 4 years ago

Diy2210 commented 4 years ago

I dev kotlin multiplatform app use IceRock MOKO-Widgets-Templates lib I ran into a setup problem How to configure SQLDelight and record values in a database. My app build.gradle: plugins { id("com.android.library") id("org.jetbrains.kotlin.multiplatform") id("dev.icerock.mobile.multiplatform") id("dev.icerock.mobile.multiplatform-resources") id("com.squareup.sqldelight") }

android { compileSdkVersion(Versions.Android.compileSdk)

defaultConfig {
    minSdkVersion(Versions.Android.minSdk)
    targetSdkVersion(Versions.Android.targetSdk)
}

}

sqldelight { database("ServerDB") { packageName = "org.example.app" } }

val mppLibs = listOf( Deps.Libs.MultiPlatform.mokoResources, Deps.Libs.MultiPlatform.mokoWidgets )

setupFramework( exports = mppLibs )

dependencies { mppLibrary(Deps.Libs.MultiPlatform.kotlinStdLib) mppLibrary(Deps.Libs.MultiPlatform.coroutines)

androidLibrary(Deps.Libs.Android.lifecycle)

mppLibs.forEach { mppLibrary(it) }

}

multiplatformResources { multiplatformResourcesPackage = "org.example.library" }

Then i create and put ServerDB.sq to commonMain/sqldelight, what next?

AlecKazakova commented 4 years ago

id recommend checking out these resources on how to get started: https://johnoreilly.dev/posts/sqldelight-multiplatform/ https://cashapp.github.io/sqldelight/ https://github.com/cashapp/sqldelight/tree/master/sample