Sha256: 9badd2325ec328ee9b08ae4f026e0ef50262d33b120aff866c3e47d90322f2d2

Contents?: true

Size: 1.92 KB

Versions: 25

Compression:

Stored size: 1.92 KB

Contents

#  Copyright 2023. Couchbase, Inc.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

# frozen_string_literal: true

require "couchbase/options"

require_relative "response_converter/kv"

module Couchbase
  module Protostellar
    class BinaryCollection
      def initialize(collection)
        @collection = collection
        @client = collection.instance_variable_get(:@client)
        @kv_request_generator = collection.instance_variable_get(:@kv_request_generator)
      end

      def append(id, content, options = Options::Append::DEFAULT)
        req = @kv_request_generator.append_request(id, content, options)
        resp = @client.send_request(req)
        ResponseConverter::KV.to_mutation_result(resp)
      end

      def prepend(id, content, options = Options::Prepend::DEFAULT)
        req = @kv_request_generator.prepend_request(id, content, options)
        resp = @client.send_request(req)
        ResponseConverter::KV.to_mutation_result(resp)
      end

      def increment(id, options = Options::Increment::DEFAULT)
        req = @kv_request_generator.increment_request(id, options)
        resp = @client.send_request(req)
        ResponseConverter::KV.to_counter_result(resp)
      end

      def decrement(id, options = Options::Decrement::DEFAULT)
        req = @kv_request_generator.decrement_request(id, options)
        resp = @client.send_request(req)
        ResponseConverter::KV.to_counter_result(resp)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
couchbase-3.5.4 lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.4-arm64-darwin lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.4-x86_64-darwin lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.4-x86_64-linux lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.4-x86_64-linux-musl lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.3-x86_64-linux-musl lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.3 lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.3-arm64-darwin lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.3-x86_64-darwin lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.3-x86_64-linux lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.2 lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.2-x86_64-linux lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.2-x86_64-darwin lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.2-x86_64-linux-musl lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.1 lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.1-x86_64-linux lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.1-x86_64-darwin-20 lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.1-arm64-darwin-22 lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.1-x86_64-linux-musl lib/couchbase/protostellar/binary_collection.rb
couchbase-3.5.0-arm64-darwin-23 lib/couchbase/protostellar/binary_collection.rb