lookup In Any Replica
@SinceCouchbase(value = "7.6" )
Content copied to clipboard
Like lookupIn, but sends the request to all replicas in addition to the active. Returns the result from whichever server node responded quickest.
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
}
Parameters
block
callback for processing the results, with LookupInReplicaResult as the receiver.
Throws
com. couchbase. client. core. error. Document Unretrievable Exception
if the document could not be retrieved from at least one location.
@SinceCouchbase(value = "7.6" )
Content copied to clipboard
Like lookupIn, but sends the request to all replicas in addition to the active. Returns the result from whichever server node responded quickest.
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
}
Throws
com. couchbase. client. core. error. Document Unretrievable Exception
if the document could not be retrieved from at least one location.