Views
- class couchbase.management.views.DesignDocument(name: str, views: dict[str, View], namespace: DesignDocumentNamespace | None = None, rev: str | None = None)
A design document: a named set of views.
- Parameters:
name (str) – The name of the design document. A
_design/ordev_prefix is removed.views (dict[str,
View]) – The views, keyed by name.namespace (
DesignDocumentNamespace, optional) – Whether the design document is in production or indevelopment.
rev (str, optional) – The revision of the design document.
- add_view(name: str, view: View) DesignDocument
Add a view, replacing any view of the same name.
- Parameters:
- Returns:
This design document, so calls can be chained.
- Return type:
- classmethod from_json(raw_json: dict[str, Any]) DesignDocument
Create a design document from a dict describing it.
- property namespace: DesignDocumentNamespace | None
Whether the design document is in production or in development.
- class couchbase.management.views.DesignDocumentNamespace(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Whether a design document is in production or in development.
A development design document indexes only part of the bucket, so its views can be tried out before they are published to production.
- DEVELOPMENT = True
- PRODUCTION = False
- class couchbase.management.views.View(map: str, reduce: str | None = None, name: str | None = None)
A view in a design document: the map function that indexes documents, and optionally a reduce function.
- Parameters:
map (str) – The JavaScript source of the map function.
reduce (str, optional) – The JavaScript source of the reduce function, or the name of a built-in one such as
_count.
name (str, optional) – Accepted and not kept: a view’s name is its key in
DesignDocument.views.
- classmethod from_json(json_view: dict[str, Any]) View
Create a view from a dict holding its
mapand, optionally, itsreduce.
- class couchbase.management.views.ViewIndexManager(impl: ViewIndexMgmtInterface)
Performs management operations on a bucket’s view design documents.
- drop_design_document(design_doc_name: str, namespace: DesignDocumentNamespace, options: DropDesignDocumentOptions | None = None, **kwargs: Unpack[DropDesignDocumentOptionsKwargs]) None
Drops an existing design document.
- Parameters:
design_doc_name (str) – The name of the design document.
namespace (
DesignDocumentNamespace) – Whether the design document is in development or production.options (
DropDesignDocumentOptions) – Optional parameters for this operation.**kwargs – keyword arguments that can be used as optional parameters for this operation.
- Raises:
InvalidArgumentException – If the design_doc_name or namespace is not given.
DesignDocumentNotFoundException – If the design document does not exist.
- get_all_design_documents(namespace: DesignDocumentNamespace, options: GetAllDesignDocumentsOptions | None = None, **kwargs: Unpack[GetAllDesignDocumentsOptionsKwargs]) Iterable[DesignDocument]
Returns every design document in a namespace.
- Parameters:
namespace (
DesignDocumentNamespace) – Whether the design document is in development or production.options (
GetAllDesignDocumentsOptions) – Optional parameters for this operation.**kwargs – keyword arguments that can be used as optional parameters for this operation.
- Returns:
The design documents.
- Return type:
Iterable[
DesignDocument]- Raises:
InvalidArgumentException – If the namespace is not given.
- get_design_document(design_doc_name: str, namespace: DesignDocumentNamespace, options: GetDesignDocumentOptions | None = None, **kwargs: Unpack[GetDesignDocumentOptionsKwargs]) DesignDocument
Returns a design document.
- Parameters:
design_doc_name (str) – The name of the design document.
namespace (
DesignDocumentNamespace) – Whether the design document is in development or production.options (
GetDesignDocumentOptions) – Optional parameters for this operation.**kwargs – keyword arguments that can be used as optional parameters for this operation.
- Returns:
The design document.
- Return type:
- Raises:
InvalidArgumentException – If the design_doc_name or namespace is not given.
DesignDocumentNotFoundException – If the design document does not exist.
- publish_design_document(design_doc_name: str, options: PublishDesignDocumentOptions | None = None, **kwargs: Unpack[PublishDesignDocumentOptionsKwargs]) None
Copies a design document from the development namespace to production.
The copy is a get followed by an upsert, and the timeout covers both.
- Parameters:
design_doc_name (str) – The name of the development design document to publish.
options (
PublishDesignDocumentOptions) – Optional parameters for this operation.**kwargs – keyword arguments that can be used as optional parameters for this operation.
- Raises:
InvalidArgumentException – If the design_doc_name is not given.
DesignDocumentNotFoundException – If the design document does not exist in the development namespace.
- upsert_design_document(design_doc_data: DesignDocument, namespace: DesignDocumentNamespace, options: UpsertDesignDocumentOptions | None = None, **kwargs: Unpack[UpsertDesignDocumentOptionsKwargs]) None
Creates a design document, or replaces one of the same name.
- Parameters:
design_doc_data (
DesignDocument) – The design document to create or replace.namespace (
DesignDocumentNamespace) – Whether the design document is in development or production.options (
UpsertDesignDocumentOptions) – Optional parameters for this operation.**kwargs – keyword arguments that can be used as optional parameters for this operation.
- Raises:
InvalidArgumentException – If the design_doc_data or namespace is not given.