英文:
Database on Jetpack compose desktop
问题
我正在使用Jetpack Compose Desktop进行开发,但在寻找有关可用于数据库存储的库的最新信息方面遇到了困难。显然,Room不是一个选项。我听说sqldelight是一个选项,但找不到任何关于设置的资源。提前感谢。
英文:
I'm developing with Jetpack Compose Desktop and having a hard time finding any up to date information on what libraries are available for database storage. Room is obviously not an option. I have heard sqldelight is an option but not able to find any resources for setup. Thanks in advance.
答案1
得分: 0
我在使用Kotlin和Compose UI构建的桌面应用程序中使用SqlDelight。以下是可能对您有帮助的资源:
https://cashapp.github.io/sqldelight/2.0.0/multiplatform_sqlite/
Build.gradle.kts
kotlin {
jvm {
jvmToolchain(Deps.JDK)
withJava()
}
sourceSets {
val commonMain by getting {
dependencies {
implementation(Deps.Koin.CORE)
//Database
with(Deps.SQLDelight) {
implementation(DRIVER)
api(RUNTIME)
api(COROUTINE_EXT)
}
}
}
val jvmMain by getting
}
}
sqldelight {
databases {
create("AppDatabase") {
packageName.set("com.mobiledevpro.database")
}
}
}
object SQLDelight {
const val DRIVER = "app.cash.sqldelight:sqlite-driver:${Versions.SQL_DELIGHT}"
const val RUNTIME = "app.cash.sqldelight:runtime:${Versions.SQL_DELIGHT}"
const val COROUTINE_EXT = "app.cash.sqldelight:coroutines-extensions:${Versions.SQL_DELIGHT}"
}
英文:
I use SqlDelight in Desktop app build with Kotlin and Compose UI. Here is a resource might help to you as well:
https://cashapp.github.io/sqldelight/2.0.0/multiplatform_sqlite/
Build.gradle.kts
kotlin {
jvm {
jvmToolchain(Deps.JDK)
withJava()
}
sourceSets {
val commonMain by getting {
dependencies {
implementation(Deps.Koin.CORE)
//Database
with(Deps.SQLDelight) {
implementation(DRIVER)
api(RUNTIME)
api(COROUTINE_EXT)
}
}
}
val jvmMain by getting
}
}
sqldelight {
databases {
create("AppDatabase") {
packageName.set("com.mobiledevpro.database")
}
}
}
object SQLDelight {
const val DRIVER = "app.cash.sqldelight:sqlite-driver:${Versions.SQL_DELIGHT}"
const val RUNTIME = "app.cash.sqldelight:runtime:${Versions.SQL_DELIGHT}"
const val COROUTINE_EXT = "app.cash.sqldelight:coroutines-extensions:${Versions.SQL_DELIGHT}"
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论