lookup In Any Replica
@SinceCouchbase(value = "7.6" )
Like lookupIn, but sends the request to all replicas in addition to the active. Returns the result from whichever server node responded quickest.
Parameters
block
callback for processing the results, with LookupInReplicaResult as the receiver.
Throws
Document Unretrievable Exception
if the document could not be retrieved from at least one location.
Samples
import com.couchbase.client.kotlin.Collection
import com.couchbase.client.kotlin.kv.LookupInSpec
fun main() {
//sampleStart
// Subdoc lookup
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}")
}
}
//sampleEnd
}
import com.couchbase.client.kotlin.Collection
import com.couchbase.client.kotlin.kv.LookupInSpec
fun main() {
//sampleStart
// Subdoc lookup without Lambda
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)}")
}
//sampleEnd
}
@SinceCouchbase(value = "7.6" )
Like lookupIn, but sends the request to all replicas in addition to the active. Returns the result from whichever server node responded quickest.
Throws
Document Unretrievable Exception
if the document could not be retrieved from at least one location.
Samples
import com.couchbase.client.kotlin.Collection
import com.couchbase.client.kotlin.kv.LookupInSpec
fun main() {
//sampleStart
// Subdoc lookup without Lambda
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)}")
}
//sampleEnd
}