Manage Scopes and Collections

      +
      Scopes and collections, which allow documents to be categorized and organized within a bucket, can be created and deleted within the Capella UI.

      Scopes and collections categorize and organize documents within a bucket. A collection is a data container within a bucket. A scope is a mechanism that groups multiple collections. Each database can hold up to 1000 scopes and up to 1000 collections. For a complete overview, see Scopes and Collections.

      Accessing Scopes in the Couchbase Capella UI

      1. Open the Buckets page for your database:

        1. With the Databases tab open, select your database.

        2. Click the Data Tools tab.

        3. In the navigation menu, click Buckets.

      2. Click the bucket with the scopes you want to view.

      Scopes View

      A bucket’s Scopes view lists all the scopes within that bucket in a tabular format, including the number of collections within each scope.

      A database’s list of scopes.

      Actions are available to create and delete scopes, and add collections to an open scope. The Bucket list allows you to switch between buckets in the current database and view their respective scopes.

      Create a Scope

      To create a scope, you need the Project Owner or Project Manager role for the project with the database where you’re creating the scope.

      1. Open the Buckets page for your database:

        1. With the Databases tab open, select your database.

        2. Click the Data Tools tab.

        3. In the navigation menu, click Buckets.

      2. Click the bucket where you want to create a scope.

      3. With the Scopes view open, click Create Scope.

      4. Enter a name for the scope.

        In the Name field, enter a scope name. A scope name can only contain the A-Z, a-z, and 0-9 characters as well as the -, _, and % symbols. It can’t start with either the _ or % symbols. It can’t be longer than 251 characters in length and is case-sensitive.

      5. Click Create Scope.

      Delete a Scope

      To delete a scope, you need the Project Owner or Project Manager role for the project with the database where you’re deleting a scope.

      Deleting a scope deletes all of the collections and documents in that scope from the database. You can only restore them from a previous backup.

      1. Open the Buckets page for your database:

        1. With the Databases tab open, select your database.

        2. Click the Data Tools tab.

        3. In the navigation menu, click Buckets.

      2. Click the bucket where you want to delete a scope.

      3. With the Scopes view open, at the end of the row of the scope you’re deleting, click the Trash icon.

      4. Confirm the delete request:

        1. Type delete into the confirmation field.

        2. Click Delete Scope.

      Accessing Collections in the Couchbase Capella UI

      To view and manage collections in a bucket, open a scope’s Collections view:

      1. Open the Buckets page for your database:

        1. With the Databases tab open, select your database.

        2. Click the Data Tools tab.

        3. In the navigation menu, click Buckets.

      2. Click the bucket with the collections you want to view.

      3. Click the scope with the collection you want to view.

      This shows the Collections view for the chosen scope.

      Collections View

      A scope’s Collections view lists all the collections within the current scope in tabular format, including a time to live (TTL) value for each.

      A database’s list of collections.

      Buttons are available to delete individual collections. You can change the scope whose collections you wish to view using the Scopes list.

      Create a Collection

      To create a collection, you need the Project Owner or Project Manager role for the project with the database where you’re creating the collection.

      1. Open the Buckets page for your database:

        1. With the Databases tab open, select your database.

        2. Click the Data Tools tab.

        3. In the navigation menu, click Buckets.

      2. Click the bucket where you want to create a collection.

      3. With the Scopes view open, click the scope where you want to create a collection.

      4. With the Collections view open, click Create Collection.

      5. Enter a name for the collection.

        In the Name field, enter a name for the new collection. A collection name can contain the A-Z, a-z, and 0-9 characters as well as the -, _, and % symbols. It can’t start with either the _ or % symbols. It can’t be longer than 251 characters in length and is case-sensitive.

      6. Enter a time to live (TTL) value.

        In the TTL field, enter an expiration time in seconds for the new collection. By default, the TTL for collections is 0, meaning it uses its bucket’s TTL value. To prevent the bucket’s TTL from setting a default expiration for your collection’s documents, set the TTL value to -1.

        For more information about expirations and collections, see Expiration.

      7. Click Create Collection.

      Delete a Collection

      To delete a collection, you need the Project Owner or Project Manager role for the project with the database where you’re deleting the collection.

      Deleting a collection deletes all of the documents within it from the database. You can restore these documents from a previous backup.
      1. Open the Buckets page for your database:

        1. With the Databases tab open, select your database.

        2. Click the Data Tools tab.

        3. In the navigation menu, click Buckets.

      2. With the Scopes view open, click the scope where you want to create a collection.

      3. With the Collections view open, at the end of the row of the collection you’re deleting, click the Trash icon.

      4. Confirm the deletion:

        1. Type delete into the confirmation field.

        2. Click Delete Collection.