Skip to content

A simple client for Azure CosmosDB 's SQL API in kotlin

License

Notifications You must be signed in to change notification settings

thunderz99/kotlin-cosmos

Repository files navigation

kotlin-cosmos - A simple Azure CosmosDB Client for kotlin

Kotlin-cosmos is a client for Azure CosmosDB 's SQL API (also called documentdb formerly). Which is an opinionated library aimed at ease of use for CRUD and find (aka. query).

Background

  • Microsoft's official Kotlin CosmosDB client is for Android
  • Microsoft's official Java CosmosDB client is verbose to use

Disclaimer

  • This is an alpha version, and features are focused to CRUD and find at present.

Quickstart

Add dependency

Maven

TODO

Gradle

TODO

Start programming

import io.github.thunderz99.cosmos.Cosmos

data class User(val id:String, val firstName:String, val lastName:String )

fun main() {
    val db = Cosmos(System.getenv("YOUR_CONNECTION_STRING")).getDatabase("Database1")
    db.createIfNotExist("Collection1")
    db.upsert("Collection1", data = User("id011", "Tom", "Banks"))
  
    val users = db.find("Collection1", filter {
        "id" > "id010",
        "lastName" to "Banks" 
    }).toList<User>()
}

Examples

Work with partitions

//TODO

Create database and collection from zero

//TODO

CRUD

//TODO

About

A simple client for Azure CosmosDB 's SQL API in kotlin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages