I got understood what you are saying . I have a similar question recently and I found its easy to solve it. Just simply follow the Android Developers Rooms Official Instructions, than it will automatically generate the codes like it's done on android target.
// your build.gradle.kts may be like:
plugins {
alias(kotlinx.plugins.jvm)
alias(kotlinx.plugins.google.ksp)
alias(androidx.plugins.room)
}
dependencies {
implementation(androidx.room.runtime)
implementation(androidx.sqlite.bundled)
ksp(androidx.room.compiler)
}
room {
schemaDirectory("$projectDir/schemas")
schemaDirectory("debug", "$projectDir/schemas/debug")
schemaDirectory("release", "$projectDir/schemas/release")
}
//database.kt
@Database(
version = 1,
entities = [
SomeEntity::class,
]
)
//@TypeConverters(Convertors::class)
abstract class SomeDatabase: RoomDatabase() {
abstract fun dao():DAO
}
//dao
@Dao
interface DAO{
some queries/inserts/deletes
}
//entity
@Entity
data class SomeEntity(
val some:String
)
than you can use your database like:
val database=Room
.databaseBuilder<JobsDatabase>("database path")
.setDriver(BundledSQLiteDriver())
.setQueryCoroutineContext(Dispatchers.IO)
.build()
database.dao().insertSomething()
database.dao().querySomething()
Than build.
It will generate the code you want.