Class: Couchbase::BinaryCollection
- Inherits:
-
Object
- Object
- Couchbase::BinaryCollection
- Defined in:
- lib/couchbase/binary_collection.rb,
lib/couchbase/binary_collection_options.rb,
/code/couchbase-ruby-client/lib/couchbase/binary_collection.rb,
/code/couchbase-ruby-client/lib/couchbase/binary_collection_options.rb
Overview
Allows to perform certain operations on non-JSON documents.
Defined Under Namespace
Classes: CounterResult
Instance Method Summary collapse
-
#append(id, content, options = Options::Append::DEFAULT) ⇒ Collection::MutationResult
Appends binary content to the document.
-
#decrement(id, options = Options::Decrement::DEFAULT) ⇒ CounterResult
Decrements the counter document by one of the number defined in the options.
-
#increment(id, options = Options::Increment::DEFAULT) ⇒ CounterResult
Increments the counter document by one of the number defined in the options.
-
#initialize(collection) ⇒ BinaryCollection
constructor
A new instance of BinaryCollection.
-
#prepend(id, content, options = Options::Prepend::DEFAULT) ⇒ Collection::MutationResult
Prepends binary content to the document.
Constructor Details
#initialize(collection) ⇒ BinaryCollection
Returns a new instance of BinaryCollection.
26 27 28 29 |
# File 'lib/couchbase/binary_collection.rb', line 26 def initialize(collection) @collection = collection @backend = collection.instance_variable_get(:@backend) end |
Instance Method Details
#append(id, content, options = Options::Append::DEFAULT) ⇒ Collection::MutationResult
Appends binary content to the document
43 44 45 46 47 48 49 50 |
# File 'lib/couchbase/binary_collection.rb', line 43 def append(id, content, = Options::Append::DEFAULT) resp = @backend.document_append(@collection.bucket_name, @collection.scope_name, @collection.name, id, content, .to_backend) Collection::MutationResult.new do |res| res.cas = resp[:cas] res.mutation_token = @collection.send(:extract_mutation_token, resp) end end |
#decrement(id, options = Options::Decrement::DEFAULT) ⇒ CounterResult
Decrements the counter document by one of the number defined in the options
107 108 109 110 111 112 113 114 115 |
# File 'lib/couchbase/binary_collection.rb', line 107 def decrement(id, = Options::Decrement::DEFAULT) resp = @backend.document_decrement(@collection.bucket_name, @collection.scope_name, @collection.name, id, .to_backend) 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 = Options::Increment::DEFAULT) ⇒ CounterResult
Increments the counter document by one of the number defined in the options
85 86 87 88 89 90 91 92 93 |
# File 'lib/couchbase/binary_collection.rb', line 85 def increment(id, = Options::Increment::DEFAULT) resp = @backend.document_increment(@collection.bucket_name, @collection.scope_name, @collection.name, id, .to_backend) 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 = Options::Prepend::DEFAULT) ⇒ Collection::MutationResult
Prepends binary content to the document
64 65 66 67 68 69 70 71 |
# File 'lib/couchbase/binary_collection.rb', line 64 def prepend(id, content, = Options::Prepend::DEFAULT) resp = @backend.document_prepend(@collection.bucket_name, @collection.scope_name, @collection.name, id, content, .to_backend) Collection::MutationResult.new do |res| res.cas = resp[:cas] res.mutation_token = @collection.send(:extract_mutation_token, resp) end end |