ANN: Couchbase Kotlin SDK 1.0.0-dp.1

We :heart: Kotlin, and we think you will too :slight_smile:

It’s finally here: the first Developer Preview of the Couchbase Kotlin SDK. Try it for yourself and share your feedback in the forum.

The Couchbase Kotlin SDK runs on the JVM. It’s built on top of the same high performance I/O core as the Couchbase Java SDK. It provides idiomatic Kotlin features like default arguments, suspend functions, and tasteful DSLs.

Documentation | API Reference | Code Samples | Source Code

Maven coordinates



import com.couchbase.client.kotlin.Cluster
import com.couchbase.client.kotlin.query.execute
import kotlinx.coroutines.runBlocking

public fun main() {
    // Assumes you have Couchbase running locally
    // and the "travel-sample" sample bucket loaded.

    // Connect and open a bucket
    val cluster = Cluster.connect("", "Administrator", "password")
    try {
        val bucket = cluster.bucket("travel-sample")
        val collection = bucket.defaultCollection()

        runBlocking {
            // Perform a N1QL query and buffer the results
            val queryResult = cluster
                .query("select * from `travel-sample` limit 3")
            queryResult.rows.forEach { println(it) }

            // Get a document from the K/V service
            val getResult = collection.get("airline_10")
            println(getResult.contentAs<Map<String, Any?>>())
    } finally {
        runBlocking { cluster.disconnect() }

What’s missing in the preview?

  • We’re still working on the Full-Text Search (FTS) API. (Turns out it’s pretty complicated!)
  • N1QL prepared statements (adhoc=false) aren’t implemented yet.

Great work @david.nault. The work around for FTS is that you can use it via N1QL:

Awesome work.

Would love to see one for CBLite too :slight_smile: