view Query
Content copied to clipboard
Queries a view on the bucket.
Samples
import com.couchbase.client.kotlin.Bucket
import com.couchbase.client.kotlin.view.DesignDocumentNamespace
import com.couchbase.client.kotlin.view.ViewMetadata
import com.couchbase.client.kotlin.view.ViewResult
import com.couchbase.client.kotlin.view.ViewSelection
import com.couchbase.client.kotlin.view.execute
fun main() {
//sampleStart
// Buffered view query, for when results are known to fit in memory
val result: ViewResult = bucket
.viewQuery(
designDocument = "myDesignDoc",
viewName = "myView",
namespace = DesignDocumentNamespace.DEVELOPMENT,
selection = ViewSelection.key("foo")
).execute()
result.rows.forEach { println(it) }
println(result.metadata)
//sampleEnd
}
import com.couchbase.client.kotlin.Bucket
import com.couchbase.client.kotlin.view.DesignDocumentNamespace
import com.couchbase.client.kotlin.view.ViewMetadata
import com.couchbase.client.kotlin.view.ViewResult
import com.couchbase.client.kotlin.view.ViewSelection
import com.couchbase.client.kotlin.view.execute
fun main() {
//sampleStart
// Streaming view query, for when results are large or unbounded
val metadata: ViewMetadata = bucket
.viewQuery(
designDocument = "myDesignDoc",
viewName = "myView",
namespace = DesignDocumentNamespace.PRODUCTION,
selection = ViewSelection.range(
startKey = "somePrefix",
endKey = "somePrefix\uefff"
)
).execute { row -> println(row) }
println(metadata)
//sampleEnd
}
Throws
com. couchbase. client. core. error. View Not Found Exception
if the view or design document is not found on the server.