Class: Couchbase::Options::View

Inherits:
Base
  • Object
show all
Defined in:
lib/couchbase/options.rb,
/home/runner/work/couchbase-ruby-client/couchbase-ruby-client/lib/couchbase/options.rb

Overview

Options for Cluster#view_query

Instance Attribute Summary collapse

Attributes inherited from Base

#client_context, #parent_span, #retry_strategy, #timeout

Instance Method Summary collapse

Constructor Details

#initialize(scan_consistency: :not_bounded, namespace: :production, skip: nil, limit: nil, start_key: nil, end_key: nil, start_key_doc_id: nil, end_key_doc_id: nil, inclusive_end: nil, group: nil, group_level: nil, key: nil, keys: nil, order: nil, reduce: nil, on_error: nil, debug: false, timeout: nil, retry_strategy: nil, client_context: nil, parent_span: nil) {|self| ... } ⇒ View

Returns a new instance of View.

Parameters:

  • scan_consistency (:not_bounded, :request_plus, :update_after) (defaults to: :not_bounded) —

    Specifies the level of consistency for the query

  • namespace (:production, :development) (defaults to: :production)
  • skip (Integer, nil) (defaults to: nil) —

    Specifies the number of results to skip from the start of the result set

  • limit (Integer, nil) (defaults to: nil) —

    Specifies the maximum number of results to return

  • start_key (#to_json, nil) (defaults to: nil) —

    Specifies the key, to which the engine has to skip before result generation

  • end_key (#to_json, nil) (defaults to: nil) —

    Specifies the key, at which the result generation has to be stopped

  • start_key_doc_id (String, nil) (defaults to: nil) —

    Specifies the document id in case #start_key gives multiple results within the index

  • end_key_doc_id (String, nil) (defaults to: nil) —

    Specifies the document id in case #end_key gives multiple results within the index

  • inclusive_end (Boolean, nil) (defaults to: nil) —

    Specifies whether the #end_key/##end_key_doc_id values should be inclusive

  • group (Boolean, nil) (defaults to: nil) —

    Specifies whether to enable grouping of the results

  • group_level (Integer, nil) (defaults to: nil) —

    Specifies the depth within the key to group the results

  • key (#to_json, nil) (defaults to: nil) —

    Specifies the key to fetch from the index

  • keys (Array<#to_json>, nil) (defaults to: nil) —

    Specifies set of the keys to fetch from the index

  • order (:ascending, :descending, nil) (defaults to: nil) —

    Specifies the order of the results that should be returned

  • reduce (Boolean, nil) (defaults to: nil) —

    Specifies whether to enable the reduction function associated with this particular view index

  • on_error (:stop, :continue, nil) (defaults to: nil) —

    Specifies the behaviour of the view engine should an error occur during the gathering of view index results which would result in only partial results being available

  • debug (Boolean, nil) (defaults to: false) —

    allows to return debug information as part of the view response

  • timeout (Integer, #in_milliseconds, nil) (defaults to: nil)
  • retry_strategy (Symbol, nil) (defaults to: nil) —

    ignored by this operation

  • client_context (Hash, nil) (defaults to: nil) —

    the client context data, if set

  • parent_span (Span, nil) (defaults to: nil) —

    if set holds the parent span, that should be used for this request

Yield Parameters:



2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
# File 'lib/couchbase/options.rb', line 2643

def initialize(scan_consistency: :not_bounded,
               namespace: :production,
               skip: nil,
               limit: nil,
               start_key: nil,
               end_key: nil,
               start_key_doc_id: nil,
               end_key_doc_id: nil,
               inclusive_end: nil,
               group: nil,
               group_level: nil,
               key: nil,
               keys: nil,
               order: nil,
               reduce: nil,
               on_error: nil,
               debug: false,
               timeout: nil,
               retry_strategy: nil,
               client_context: nil,
               parent_span: nil)
  super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span, &nil)

  @scan_consistency = scan_consistency
  @namespace = namespace
  @skip = skip
  @limit = limit
  @start_key = start_key
  @end_key = end_key
  @start_key_doc_id = start_key_doc_id
  @end_key_doc_id = end_key_doc_id
  @inclusive_end = inclusive_end
  @group = group
  @group_level = group_level
  @key = key
  @keys = keys
  @order = order
  @reduce = reduce
  @on_error = on_error
  @debug = debug
  @raw_parameters = {}
  yield self if block_given?
end

Instance Attribute Details

#debug ⇒ Boolean?

Returns:

  • (Boolean, nil)


2615
2616
2617
# File 'lib/couchbase/options.rb', line 2615

def debug
  @debug
end

#end_key ⇒ #to_json?

Returns:

  • (#to_json, nil)


2604
2605
2606
# File 'lib/couchbase/options.rb', line 2604

def end_key
  @end_key
end

#end_key_doc_id ⇒ String?

Returns:

  • (String, nil)


2606
2607
2608
# File 'lib/couchbase/options.rb', line 2606

def end_key_doc_id
  @end_key_doc_id
end

#group ⇒ Boolean?

Returns:

  • (Boolean, nil)


2608
2609
2610
# File 'lib/couchbase/options.rb', line 2608

def group
  @group
end

#group_level ⇒ Integer?

Returns:

  • (Integer, nil)


2609
2610
2611
# File 'lib/couchbase/options.rb', line 2609

def group_level
  @group_level
end

#inclusive_end ⇒ Boolean?

Returns:

  • (Boolean, nil)


2607
2608
2609
# File 'lib/couchbase/options.rb', line 2607

def inclusive_end
  @inclusive_end
end

#key ⇒ #to_json?

Returns:

  • (#to_json, nil)


2610
2611
2612
# File 'lib/couchbase/options.rb', line 2610

def key
  @key
end

#keys ⇒ Array<#to_json>?

Returns:

  • (Array<#to_json>, nil)


2611
2612
2613
# File 'lib/couchbase/options.rb', line 2611

def keys
  @keys
end

#limit ⇒ Integer

Returns:

  • (Integer)


2602
2603
2604
# File 'lib/couchbase/options.rb', line 2602

def limit
  @limit
end

#namespace ⇒ Symbol

Returns:

  • (Symbol)


2600
2601
2602
# File 'lib/couchbase/options.rb', line 2600

def namespace
  @namespace
end

#on_error ⇒ Symbol?

Returns:

  • (Symbol, nil)


2614
2615
2616
# File 'lib/couchbase/options.rb', line 2614

def on_error
  @on_error
end

#order ⇒ Symbol?

Returns:

  • (Symbol, nil)


2612
2613
2614
# File 'lib/couchbase/options.rb', line 2612

def order
  @order
end

#reduce ⇒ Boolean?

Returns:

  • (Boolean, nil)


2613
2614
2615
# File 'lib/couchbase/options.rb', line 2613

def reduce
  @reduce
end

#scan_consistency ⇒ Symbol

Returns:

  • (Symbol)


2599
2600
2601
# File 'lib/couchbase/options.rb', line 2599

def scan_consistency
  @scan_consistency
end

#skip ⇒ Integer

Returns:

  • (Integer)


2601
2602
2603
# File 'lib/couchbase/options.rb', line 2601

def skip
  @skip
end

#start_key ⇒ #to_json?

Returns:

  • (#to_json, nil)


2603
2604
2605
# File 'lib/couchbase/options.rb', line 2603

def start_key
  @start_key
end

#start_key_doc_id ⇒ String?

Returns:

  • (String, nil)


2605
2606
2607
# File 'lib/couchbase/options.rb', line 2605

def start_key_doc_id
  @start_key_doc_id
end

Instance Method Details

#raw(key, value) ⇒ Object

Allows providing custom query-string parameters for advanced usage

The SDK form-encodes the name and the value. A parameter that shares its name with a typed option is sent in addition to it.

Examples:

Pass parameters as raw values

options.raw("limit", 2)       # limit=2
options.raw(:key, '"k2"')     # key="k2", form-encoded

Parameters:

  • key (String, Symbol) —

    the parameter name

  • value (Object) —

    the parameter value. A String must already be in the form the view engine expects, such as JSON for key or keys. Any other value is converted with JSON.generate.



2699
2700
2701
# File 'lib/couchbase/options.rb', line 2699

def raw(key, value)
  @raw_parameters[key.to_s] = value.is_a?(String) ? value : JSON.generate(value)
end