Sha256: 35f7c10243cfb365a3d7ddf26fa0131ab5783aea182e66bf1288538433ee2ca7

Contents?: true

Size: 1.76 KB

Versions: 25

Compression:

Stored size: 1.76 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/errors"
require "couchbase/options"

require_relative "request_generator/query"
require_relative "response_converter/query"
require_relative "collection"

module Couchbase
  module Protostellar
    class Scope
      attr_reader :bucket_name
      attr_reader :name

      def initialize(client, bucket_name, name)
        @client = client
        @bucket_name = bucket_name
        @name = name

        @query_request_generator = RequestGenerator::Query.new(bucket_name: @bucket_name, scope_name: @name)
      end

      def collection(name)
        Collection.new(@client, @bucket_name, @name, name)
      end

      def query(statement, options = Couchbase::Options::Query::DEFAULT)
        req = @query_request_generator.query_request(statement, options)
        resps = @client.send_request(req)
        ResponseConverter::Query.to_query_result(resps)
      end

      def search_query(...)
        raise Error::FeatureNotAvailable, "scope search not supported in #{Protostellar::NAME} mode"
      end

      def search(...)
        raise Error::FeatureNotAvailable, "scope search not supported in #{Protostellar::NAME} mode"
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

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