Class: Couchbase::BinaryCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/binary_collection.rb,
lib/couchbase/binary_collection_options.rb

Defined Under Namespace

Classes: AppendOptions, CounterResult, DecrementOptions, IncrementOptions, PrependOptions

Instance Method Summary collapse

Constructor Details

#initialize(collection) ⇒ BinaryCollection

Returns a new instance of BinaryCollection.

Parameters:



22
23
24
25
# File 'lib/couchbase/binary_collection.rb', line 22

def initialize(collection)
  @collection = collection
  @backend = collection.instance_variable_get("@backend")
end

Instance Method Details

#append(id, content, options = AppendOptions.new) ⇒ Collection::MutationResult

Appends binary content to the document

Parameters:

  • id (String)

    the document id which is used to uniquely identify it

  • content (String)

    the binary content to append to the document

  • options (AppendOptions) (defaults to: AppendOptions.new)

    custom options to customize the request

Returns:



34
# File 'lib/couchbase/binary_collection.rb', line 34

def append(id, content, options = AppendOptions.new) end

#decrement(id, options = DecrementOptions.new) ⇒ CounterResult

Decrements the counter document by one of the number defined in the options

Parameters:

  • id (String)

    the document id which is used to uniquely identify it

  • options (DecrementOptions) (defaults to: DecrementOptions.new)

    custom options to customize the request

Returns:



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/couchbase/binary_collection.rb', line 73

def decrement(id, options = DecrementOptions.new)
  resp = @backend.document_decrement(@collection.bucket_name, "#{@collection.scope_name}.#{@collection.name}", id,
                                     options.timeout,
                                     {
                                       delta: options.delta,
                                       initial_value: options.initial,
                                       expiry: options.expiry,
                                       durability_level: options.durability_level,
                                     })
  CounterResult.new do |res|
    res.cas = resp[:cas]
    res.content = resp[:content]
    res.mutation_token = @collection.send(:extract_mutation_token, resp)
  end
end

#increment(id, options = IncrementOptions.new) ⇒ CounterResult

Increments the counter document by one of the number defined in the options

Parameters:

  • id (String)

    the document id which is used to uniquely identify it

  • options (IncrementOptions) (defaults to: IncrementOptions.new)

    custom options to customize the request

Returns:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/couchbase/binary_collection.rb', line 51

def increment(id, options = IncrementOptions.new)
  resp = @backend.document_increment(@collection.bucket_name, "#{@collection.scope_name}.#{@collection.name}", id,
                                     options.timeout,
                                     {
                                       delta: options.delta,
                                       initial_value: options.initial,
                                       expiry: options.expiry,
                                       durability_level: options.durability_level,
                                     })
  CounterResult.new do |res|
    res.cas = resp[:cas]
    res.content = resp[:content]
    res.mutation_token = @collection.send(:extract_mutation_token, resp)
  end
end

#prepend(id, content, options = PrependOptions.new) ⇒ Collection::MutationResult

Prepends binary content to the document

Parameters:

  • id (String)

    the document id which is used to uniquely identify it

  • content (String)

    the binary content to prepend to the document

  • options (PrependOptions) (defaults to: PrependOptions.new)

    custom options to customize the request

Returns:



43
# File 'lib/couchbase/binary_collection.rb', line 43

def prepend(id, content, options = PrependOptions.new) end