Retrieves specific fields of a document.
Samples
import com.couchbase.client.kotlin.Collection
import com.couchbase.client.kotlin.kv.LookupInSpec
fun main() {
val spec = object : LookupInSpec() {
val sku = get("sku")
val hasPrice = exists("price")
val orderCount = count("orders")
}
collection.lookupIn(documentId, spec) {
println("cas: $cas")
with(spec) {
println("sku: ${sku.contentAs<String>()}")
println("has price: ${hasPrice.value}")
println("order count: ${orderCount.value}")
}
}
}
Target: JVMRunning on v.2.1.10
import com.couchbase.client.kotlin.Collection
import com.couchbase.client.kotlin.kv.LookupInSpec
fun main() {
val spec = object : LookupInSpec() {
val sku = get("sku")
val hasPrice = exists("price")
val orderCount = count("orders")
}
val result = collection.lookupIn(documentId, spec)
println("cas: $result.cas")
with(spec) {
println("sku: ${sku.contentAs<String>(result)}")
println("has price: ${hasPrice.get(result)}")
println("order count: ${orderCount.get(result)}")
}
}
Target: JVMRunning on v.2.1.10
Parameters
callback for processing the results, with LookupInResult as the receiver.
Retrieves specific fields of a document.
Samples
import com.couchbase.client.kotlin.Collection
import com.couchbase.client.kotlin.kv.LookupInSpec
fun main() {
val spec = object : LookupInSpec() {
val sku = get("sku")
val hasPrice = exists("price")
val orderCount = count("orders")
}
collection.lookupIn(documentId, spec) {
println("cas: $cas")
with(spec) {
println("sku: ${sku.contentAs<String>()}")
println("has price: ${hasPrice.value}")
println("order count: ${orderCount.value}")
}
}
}
Target: JVMRunning on v.2.1.10
import com.couchbase.client.kotlin.Collection
import com.couchbase.client.kotlin.kv.LookupInSpec
fun main() {
val spec = object : LookupInSpec() {
val sku = get("sku")
val hasPrice = exists("price")
val orderCount = count("orders")
}
val result = collection.lookupIn(documentId, spec)
println("cas: $result.cas")
with(spec) {
println("sku: ${sku.contentAs<String>(result)}")
println("has price: ${hasPrice.get(result)}")
println("order count: ${orderCount.get(result)}")
}
}
Target: JVMRunning on v.2.1.10