CouchbaseGetScope

Get a Couchbase scope instance within a bucket.

Syntax

couchbaseGetScope(cacheName, [scopeName])

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

Returns

Returns the Couchbase Scope instance with access to:

  • Collection management

  • Query execution scoped to this scope

  • Analytics scoped to this scope

Examples

Get Default Scope

Get Custom Scope

Execute Scoped Queries

Multiple Scopes

Scope Organization

Notes

  • Default scope is _default (Couchbase standard)

  • Scopes provide namespace isolation within a bucket

  • Useful for multi-tenant applications

  • Each scope can have multiple collections

  • Scope names are case-sensitive

  • Scope must exist in Couchbase or operation will fail

Scope Benefits

  • Namespace isolation - Separate data logically within one bucket

  • Access control - Grant permissions per scope

  • Organization - Group related collections together

  • Multi-tenancy - Isolate tenant data within scopes

  • Environment separation - dev/staging/prod in same bucket

See Also

Last updated

Was this helpful?