Sqkon
Type-safe JSONB-powered key-value store for Kotlin Multiplatform.
Install
// build.gradle.kts
dependencies {
implementation("com.mercury.sqkon:library:{{ site.sqkon_version }}")
}
30-second taste
@Serializable
data class Merchant(
val id: String,
val name: String,
val category: String,
)
// Android needs context + scope; JVM needs scope only.
val sqkon = Sqkon(context = applicationContext, scope = appScope)
val merchants = sqkon.keyValueStorage<Merchant>("merchants")
// Insert (sync) — Sqkon dispatches the SQLite work internally.
merchants.insert("m_1", Merchant("m_1", "Chipotle", "Food"))
// Observe — emits whenever the store changes. Collect from a coroutine.
appScope.launch {
merchants.selectAll().collect { list ->
println("Now have ${list.size} merchants")
}
}
// One-shot reads use Flow.first() inside a suspend block.
suspend fun loadFood(): List<Merchant> =
merchants.select(where = Merchant::category eq "Food").first()