Skip to content

Instantly share code, notes, and snippets.

@cheptsov
Created July 6, 2014 22:03
Show Gist options
  • Save cheptsov/e99e5fa7343143008b2b to your computer and use it in GitHub Desktop.
Save cheptsov/e99e5fa7343143008b2b to your computer and use it in GitHub Desktop.
Kotlin NoSQL API for MongoDB has been rewritten to use RxJava (see https://github.com/cheptsov/kotlin-nosql for details):
// Get a document
Albums.find { details.artistId.equal(artistId) }.subscribe(onNext = { album ->
}, onError = {
})
// Get selected fields of a document
Albums.find { id.equal(albumId) }.projection { sku + details.title + pricing }.subscribe(onNext = {
val (sku, title, pricing) = it
}, onError = {
})
// Update selected fields of a document
Products.find { sku.equal("00e8da9b") }.projection { pricing.retail + pricing.savings + pricing.list }.update(1150, 50, 1250).subscribe(onComplete = {
}, onError = {
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment