Class: Couchbase::Management::CollectionManager
- Inherits:
-
Object
- Object
- Couchbase::Management::CollectionManager
- Defined in:
- lib/couchbase/management/collection_manager.rb,
/Users/sergey.auseyau/code/couchbase-ruby-client/lib/couchbase/management/collection_manager.rb more...
Defined Under Namespace
Classes: CreateCollectionOptions, CreateScopeOptions, DropCollectionOptions, DropScopeOptions, GetAllScopesOptions, GetScopeOptions
Instance Method Summary collapse
-
#create_collection(collection, options = CreateCollectionOptions.new) ⇒ Object
Creates a new collection.
-
#create_scope(scope_name, options = CreateScopeOptions.new) ⇒ Object
Creates a new scope.
-
#drop_collection(collection, options = DropCollectionOptions.new) ⇒ Object
Removes a collection.
-
#drop_scope(scope_name, options = DropScopeOptions.new) ⇒ Object
Removes a scope.
-
#get_all_scopes(options = GetAllScopesOptions.new) ⇒ Array<ScopeSpec>
Get all scopes.
-
#get_scope(scope_name, options = GetScopeOptions.new) ⇒ ScopeSpec
Removes a scope.
-
#initialize(backend, bucket_name) ⇒ CollectionManager
constructor
A new instance of CollectionManager.
Constructor Details
#initialize(backend, bucket_name) ⇒ CollectionManager
Returns a new instance of CollectionManager.
24 25 26 27 |
# File 'lib/couchbase/management/collection_manager.rb', line 24 def initialize(backend, bucket_name) @backend = backend @bucket_name = bucket_name end |
Instance Method Details
#create_collection(collection, options = CreateCollectionOptions.new) ⇒ Object
Creates a new collection
96 97 98 |
# File 'lib/couchbase/management/collection_manager.rb', line 96 def create_collection(collection, = CreateCollectionOptions.new) @backend.collection_create(@bucket_name, collection.scope_name, collection.name, collection.max_expiry, .timeout) end |
#create_scope(scope_name, options = CreateScopeOptions.new) ⇒ Object
Creates a new scope
70 71 72 |
# File 'lib/couchbase/management/collection_manager.rb', line 70 def create_scope(scope_name, = CreateScopeOptions.new) @backend.scope_create(@bucket_name, scope_name, .timeout) end |
#drop_collection(collection, options = DropCollectionOptions.new) ⇒ Object
Removes a collection
108 109 110 |
# File 'lib/couchbase/management/collection_manager.rb', line 108 def drop_collection(collection, = DropCollectionOptions.new) @backend.collection_drop(@bucket_name, collection.scope_name, collection.name, .timeout) end |
#drop_scope(scope_name, options = DropScopeOptions.new) ⇒ Object
Removes a scope
82 83 84 |
# File 'lib/couchbase/management/collection_manager.rb', line 82 def drop_scope(scope_name, = DropScopeOptions.new) @backend.scope_drop(@bucket_name, scope_name, .timeout) end |
#get_all_scopes(options = GetAllScopesOptions.new) ⇒ Array<ScopeSpec>
Get all scopes
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/couchbase/management/collection_manager.rb', line 34 def get_all_scopes( = GetAllScopesOptions.new) res = @backend.scope_get_all(@bucket_name, .timeout) res[:scopes].map do |s| ScopeSpec.new do |scope| scope.name = s[:name] scope.collections = s[:collections].map do |c| CollectionSpec.new do |collection| collection.name = c[:name] collection.scope_name = s[:name] end end end end end |
#get_scope(scope_name, options = GetScopeOptions.new) ⇒ ScopeSpec
Removes a scope
57 58 59 60 |
# File 'lib/couchbase/management/collection_manager.rb', line 57 def get_scope(scope_name, = GetScopeOptions.new) get_all_scopes(GetAllScopesOptions.new { |o| o.timeout = .timeout }) .find { |scope| scope.name == scope_name } or raise Error::ScopeNotFound, "unable to find scope #{scope_name}" end |