Class Scope

java.lang.Object
com.couchbase.client.java.Scope

@Volatile
public class Scope
extends Object
The scope identifies a group of collections and allows high application density as a result.

If no scope is explicitly provided, the default scope is used.

Since:
3.0.0
  • Method Details

    • name

      public String name()
      The name of the scope.
      Returns:
      the name of the scope.
    • bucketName

      public String bucketName()
      The name of the bucket this scope is attached to.
    • async

      public AsyncScope async()
      Returns the underlying async scope.
    • reactive

      public ReactiveScope reactive()
      Provides access to the related ReactiveScope.
    • core

      @Volatile public Core core()
      Provides access to the underlying Core.

      This is advanced API, use with care!

    • environment

      public ClusterEnvironment environment()
      Provides access to the configured ClusterEnvironment for this scope.
    • collection

      @Volatile public Collection collection​(String collectionName)
      Opens a collection for this scope with an explicit name.
      Parameters:
      collectionName - the collection name.
      Returns:
      the requested collection if successful.
    • query

      @Volatile public QueryResult query​(String statement)
      Performs a N1QL query with default QueryOptions in a Scope
      Parameters:
      statement - the N1QL query statement.
      Returns:
      the QueryResult once the response arrives successfully.
      Throws:
      TimeoutException - if the operation times out before getting a result.
      CouchbaseException - for all other error reasons (acts as a base type and catch-all).
    • query

      @Volatile public QueryResult query​(String statement, QueryOptions options)
      Performs a N1QL query with custom QueryOptions in a Scope
      Parameters:
      statement - the N1QL query statement as a raw string.
      options - the custom options for this query.
      Returns:
      the QueryResult once the response arrives successfully.
      Throws:
      TimeoutException - if the operation times out before getting a result.
      CouchbaseException - for all other error reasons (acts as a base type and catch-all).
    • analyticsQuery

      @Volatile public AnalyticsResult analyticsQuery​(String statement)
      Performs an Analytics query with default AnalyticsOptions on a scope
      Parameters:
      statement - the Analytics query statement as a raw string.
      Returns:
      the AnalyticsResult once the response arrives successfully.
      Throws:
      TimeoutException - if the operation times out before getting a result.
      CouchbaseException - for all other error reasons (acts as a base type and catch-all).
    • analyticsQuery

      @Volatile public AnalyticsResult analyticsQuery​(String statement, AnalyticsOptions options)
      Performs an Analytics query with custom AnalyticsOptions on a scope
      Parameters:
      statement - the Analytics query statement as a raw string.
      options - the custom options for this query.
      Returns:
      the AnalyticsResult once the response arrives successfully.
      Throws:
      TimeoutException - if the operation times out before getting a result.
      CouchbaseException - for all other error reasons (acts as a base type and catch-all).