CouchbaseGetCollection

Get a Couchbase collection instance for document operations.

Syntax

couchbaseGetCollection(cacheName, [scopeName], [collectionName])

Parameters

Parameter
Type
Required
Default
Description

cacheName

String

Yes

-

Name of the cache configuration

scopeName

String

No

_default

Name of the scope within the bucket

collectionName

String

No

_default

Name of the collection within the scope

Returns

Returns the Couchbase Collection instance with access to:

  • Document CRUD operations (get, insert, upsert, replace, remove)

  • Binary operations

  • Subdocument operations

  • Query execution

  • Full-text search

Examples

Get Default Collection

Get Custom Collection

Multiple Collections

Document Operations

Subdocument Operations

Binary Operations

Notes

  • Default collection is _default in _default scope

  • Collections provide document-level organization within scopes

  • Collection names are case-sensitive

  • Collection must exist in Couchbase or operation will fail

  • Most cache operations use the default collection automatically

  • Direct collection access is for advanced scenarios

Collection Benefits

  • Document type isolation - Separate users, orders, products, etc.

  • Schema flexibility - Different document structures per collection

  • Index optimization - Create indexes specific to collection

  • Access control - Grant permissions per collection

  • Query performance - Queries run faster on smaller collections

See Also

Last updated

Was this helpful?