I have a proyect with compose multiplatform using sqldelight to manage the data base, Ios and Android are working fine but the JS web, execute fine but the database isn’t init with the configured tables, and return the error WebWorkerException: {"message":"no such table: Configs","name":"Error"}
.
this is my driver Class for JS module
actual class DatabaseDriverFactory : KoinComponent {
actual suspend fun createDriver(): SqlDriver {
val driver = WebWorkerDriver(
Worker(
js("""new URL("@cashapp/sqldelight-sqljs-worker/sqljs.worker.js", import.meta.url)""")
)
)
try {
MyDataBase.Schema.create(driver).await()
}catch (e:Exception){
println("error when create ${e.message}")
}
return driver
}
}
my JS Gradle confiiguration
jsMain.dependencies {
implementation(libs.ktor.client.httpjs)
implementation(libs.web.drive)
implementation(npm("@cashapp/sqldelight-sqljs-worker", "2.0.2"))
implementation(npm("sql.js", "1.10.3"))
implementation(devNpm("copy-webpack-plugin", "12.0.2"))
}
sqldelight config
sqldelight {
databases {
create("MyDataBase") {
packageName.set("com.test.compose.mycompose")
srcDirs.setFrom("src/commonMain/sqldelight")
schemaOutputDirectory.set(file("src/commonMain/sqldelight"))
generateAsync = true
deriveSchemaFromMigrations.set(true)
verifyMigrations.set(true)
}
}
}
I don’t know if I miss some config.
I follow this documentation
https://cashapp.github.io/sqldelight/2.0.2/js_sqlite/multiplatform/
to config my proyect, I updated to recent sql.js librarry and copy-webpack-plugin but nothing fix it.
Deybeer Gonzalez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.