Class: Couchbase::Bucket
- Inherits:
-
Object
- Object
- Couchbase::Bucket
- Defined in:
- lib/couchbase/bucket.rb,
lib/couchbase/view_options.rb,
/home/runner/work/couchbase-ruby-client/couchbase-ruby-client/lib/couchbase/bucket.rb,
/home/runner/work/couchbase-ruby-client/couchbase-ruby-client/lib/couchbase/view_options.rb
Overview
Provides access to a Couchbase bucket APIs
Defined Under Namespace
Classes: ViewMetaData, ViewResult, ViewRow
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
Name of the bucket.
Instance Method Summary collapse
-
#collection(collection_name) ⇒ Collection
Opens the named collection in the default scope of the bucket.
- #collections ⇒ Management::CollectionManager
-
#default_collection ⇒ Collection
Opens the default collection for this bucket.
-
#default_scope ⇒ Scope
Get default scope.
-
#ping(options = Options::Ping::DEFAULT) ⇒ PingResult
Performs application-level ping requests against services in the couchbase cluster.
-
#scope(scope_name) ⇒ Scope
Get a named scope.
-
#view_indexes ⇒ Management::ViewIndexManager
deprecated
Deprecated.
Views are deprecated in Couchbase Server 7.0+, and will be removed from a future server version. Views are not compatible with the Magma storage engine. Instead of views, use indexes and queries using the Index Service (GSI) and the Query Service (SQL++).
-
#view_query(design_document_name, view_name, options = Options::View::DEFAULT) ⇒ ViewResult
deprecated
Deprecated.
Views are deprecated in Couchbase Server 7.0+, and will be removed from a future server version. Views are not compatible with the Magma storage engine. Instead of views, use indexes and queries using the Index Service (GSI) and the Query Service (SQL++).
Instance Attribute Details
#name ⇒ String (readonly)
Returns name of the bucket.
28 29 30 |
# File 'lib/couchbase/bucket.rb', line 28 def name @name end |
Instance Method Details
#collection(collection_name) ⇒ Collection
Opens the named collection in the default scope of the bucket
63 64 65 |
# File 'lib/couchbase/bucket.rb', line 63 def collection(collection_name) default_scope.collection(collection_name) end |
#collections ⇒ Management::CollectionManager
112 113 114 |
# File 'lib/couchbase/bucket.rb', line 112 def collections Management::CollectionManager.new(@backend, @name, @observability) end |
#default_collection ⇒ Collection
Opens the default collection for this bucket
70 71 72 |
# File 'lib/couchbase/bucket.rb', line 70 def default_collection Collection.new(@backend, @name, "_default", "_default", @observability) end |
#default_scope ⇒ Scope
Get default scope
45 46 47 |
# File 'lib/couchbase/bucket.rb', line 45 def default_scope Scope.new(@backend, @name, "_default", @observability) end |
#ping(options = Options::Ping::DEFAULT) ⇒ PingResult
Performs application-level ping requests against services in the couchbase cluster
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/couchbase/bucket.rb', line 130 def ping( = Options::Ping::DEFAULT) @observability.record_operation(Observability::OP_PING, .parent_span, self) do |_obs_handler| resp = @backend.ping(@name, .to_backend) PingResult.new do |res| res.version = resp[:version] res.id = resp[:id] res.sdk = resp[:sdk] resp[:services].each do |type, svcs| res.services[type] = svcs.map do |svc| PingResult::ServiceInfo.new do |info| info.id = svc[:id] info.state = svc[:state] info.latency = svc[:latency] info.remote = svc[:remote] info.local = svc[:local] info.error = svc[:error] end end end end end end |
#scope(scope_name) ⇒ Scope
Get a named scope
54 55 56 |
# File 'lib/couchbase/bucket.rb', line 54 def scope(scope_name) Scope.new(@backend, @name, scope_name, @observability) end |
#view_indexes ⇒ Management::ViewIndexManager
Views are deprecated in Couchbase Server 7.0+, and will be removed from a future server version. Views are not compatible with the Magma storage engine. Instead of views, use indexes and queries using the Index Service (GSI) and the Query Service (SQL++).
121 122 123 |
# File 'lib/couchbase/bucket.rb', line 121 def view_indexes Management::ViewIndexManager.new(@backend, @name, @observability) end |
#view_query(design_document_name, view_name, options = Options::View::DEFAULT) ⇒ ViewResult
Views are deprecated in Couchbase Server 7.0+, and will be removed from a future server version. Views are not compatible with the Magma storage engine. Instead of views, use indexes and queries using the Index Service (GSI) and the Query Service (SQL++).
Performs query to view index.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/couchbase/bucket.rb', line 92 def view_query(design_document_name, view_name, = Options::View::DEFAULT) @observability.record_operation(Observability::OP_VIEW_QUERY, .parent_span, self, :views) do |obs_handler| resp = @backend.document_view(@name, design_document_name, view_name, .namespace, .to_backend, obs_handler) ViewResult.new do |res| res. = ViewMetaData.new do || .total_rows = resp[:meta][:total_rows] .debug_info = resp[:meta][:debug_info] end res.rows = resp[:rows].map do |entry| ViewRow.new do |row| row.id = entry[:id] if entry.key?(:id) row.key = JSON.parse(entry[:key]) row.value = JSON.parse(entry[:value]) end end end end end |