Class: Couchbase::Options::View

Inherits:
Base
  • Object
show all
Defined in:
lib/couchbase/options.rb

Overview

Options for Cluster#view_query

Constant Summary collapse

DEFAULT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

View.new.freeze

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 (Proc, nil) (defaults to: nil)

    the custom retry strategy, if set

  • 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:



2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
# File 'lib/couchbase/options.rb', line 2523

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)

  @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
  yield self if block_given?
end

Instance Attribute Details

#debugBoolean?

Returns:

  • (Boolean, nil)


2495
2496
2497
# File 'lib/couchbase/options.rb', line 2495

def debug
  @debug
end

#end_key#to_json?

Returns:

  • (#to_json, nil)


2484
2485
2486
# File 'lib/couchbase/options.rb', line 2484

def end_key
  @end_key
end

#end_key_doc_idString?

Returns:

  • (String, nil)


2486
2487
2488
# File 'lib/couchbase/options.rb', line 2486

def end_key_doc_id
  @end_key_doc_id
end

#groupBoolean?

Returns:

  • (Boolean, nil)


2488
2489
2490
# File 'lib/couchbase/options.rb', line 2488

def group
  @group
end

#group_levelInteger?

Returns:

  • (Integer, nil)


2489
2490
2491
# File 'lib/couchbase/options.rb', line 2489

def group_level
  @group_level
end

#inclusive_endBoolean?

Returns:

  • (Boolean, nil)


2487
2488
2489
# File 'lib/couchbase/options.rb', line 2487

def inclusive_end
  @inclusive_end
end

#key#to_json?

Returns:

  • (#to_json, nil)


2490
2491
2492
# File 'lib/couchbase/options.rb', line 2490

def key
  @key
end

#keysArray<#to_json>?

Returns:

  • (Array<#to_json>, nil)


2491
2492
2493
# File 'lib/couchbase/options.rb', line 2491

def keys
  @keys
end

#limitInteger

Returns:

  • (Integer)


2482
2483
2484
# File 'lib/couchbase/options.rb', line 2482

def limit
  @limit
end

#namespaceSymbol

Returns:

  • (Symbol)


2480
2481
2482
# File 'lib/couchbase/options.rb', line 2480

def namespace
  @namespace
end

#on_errorSymbol?

Returns:

  • (Symbol, nil)


2494
2495
2496
# File 'lib/couchbase/options.rb', line 2494

def on_error
  @on_error
end

#orderSymbol?

Returns:

  • (Symbol, nil)


2492
2493
2494
# File 'lib/couchbase/options.rb', line 2492

def order
  @order
end

#reduceBoolean?

Returns:

  • (Boolean, nil)


2493
2494
2495
# File 'lib/couchbase/options.rb', line 2493

def reduce
  @reduce
end

#scan_consistencySymbol

Returns:

  • (Symbol)


2479
2480
2481
# File 'lib/couchbase/options.rb', line 2479

def scan_consistency
  @scan_consistency
end

#skipInteger

Returns:

  • (Integer)


2481
2482
2483
# File 'lib/couchbase/options.rb', line 2481

def skip
  @skip
end

#start_key#to_json?

Returns:

  • (#to_json, nil)


2483
2484
2485
# File 'lib/couchbase/options.rb', line 2483

def start_key
  @start_key
end

#start_key_doc_idString?

Returns:

  • (String, nil)


2485
2486
2487
# File 'lib/couchbase/options.rb', line 2485

def start_key_doc_id
  @start_key_doc_id
end

Instance Method Details

#raw(key, value) ⇒ Object

Allows providing custom JSON key/value pairs for advanced usage

Parameters:

  • key (String)

    the parameter name (key of the JSON property)

  • value (Object)

    the parameter value (value of the JSON property)



2570
2571
2572
# File 'lib/couchbase/options.rb', line 2570

def raw(key, value)
  @raw_parameters[key] = JSON.generate(value)
end

#to_backendObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
# File 'lib/couchbase/options.rb', line 2575

def to_backend
  {
    timeout: Utils::Time.extract_duration(@timeout),
    scan_consistency: @scan_consistency,
    skip: @skip,
    limit: @limit,
    start_key: (JSON.generate(@start_key) unless @start_key.nil?),
    end_key: (JSON.generate(@end_key) unless @end_key.nil?),
    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: (JSON.generate(@key) unless @key.nil?),
    keys: @keys&.map { |key| JSON.generate(key) },
    order: @order,
    reduce: @reduce,
    on_error: @on_error,
    debug: @debug,
  }
end