The Couchbase Enterprise Server 6.5 Developer Preview provides collections and scopes. Only a subset of the planned functionality is included, in order to support early access and experimentation.
A collection is a data container, defined on Couchbase Server, within a bucket whose type is either Couchbase or Ephemeral. Up to 1000 collections can be created per bucket. Bucket-items can optionally be assigned to different collections according to content-type. For example, within a bucket that contains travel information, documents that relate specifically to airports might be assigned to an airports collection, while documents that relate to hotels might be assigned to a hotels collection, and so on.
A scope is a mechanism for the grouping of multiple collections. Up to 100 scopes can be created per bucket. Collection-names must be unique within their scope. Collections might be assigned to different scopes according to content-type, or to deployment-phase (ie, test versus production). Applications can be assigned per-scope access-rights; allowing each application to access only those collections it requires.
User-defined scopes and collections must be assigned user-defined names. Such names:
Must be between 1 and 30 characters in length.
Can only contain the characters
0-9, and the symbols
Cannot start with
In the Developer Preview, every created bucket is automatically given a default scope, and within it, a default collection.
Each is named
All documents created within the bucket without reference to specific scopes or collections are saved in the default collection, within the default scope.
The default scope and collection cannot be dropped.
Collections and scopes exist within buckets. Therefore, to test collections and scopes, at least one bucket must be created. The following options are available for bucket-creation:
The examples provided in this section use a bucket named
testBucket, which is created in turn with the REST API and CLI.
Note that the CLI examples demonstrate how to use the
cbstats command to return information on collections, including the number of documents each contains.
To provide documents to be counted, the
cbc create CLI facility is used.
This section provides example-sequences, whereby system set-up and use of REST and CLI procedures are demonstrated. Additionally, it provides a reference page for each REST method.
For examples of using the REST API, see Collections via REST.
For examples of using the CLI, see Collections via CLI.
For the REST reference pages for collections, see REST API Reference.
cbstats reference pages for collections, see cbstats Reference.