Couchbase icon

Couchbase

Couchbase node to insert, update, retrieve, and delete data from a Couchbase database using KV, Query and Search services

Actions7

Overview

This node integrates with a Couchbase database to perform various document operations, including creating, reading, updating (upserting), and deleting documents within specified buckets, scopes, and collections. The "Upsert" operation specifically allows users to insert a new document or update an existing one by providing a document ID and its JSON content.

Common scenarios for this node include:

  • Synchronizing data from other systems into Couchbase.
  • Maintaining up-to-date records where documents may need to be created or updated dynamically.
  • Managing application state or user profiles stored as JSON documents in Couchbase.

Practical example:

  • A workflow that receives user profile updates and uses the Upsert operation to ensure the latest profile information is saved in Couchbase without needing to check if the document already exists.

Properties

Name Meaning
Couchbase Bucket The target Couchbase bucket where the document resides. Can be selected from a list or entered manually.
Couchbase Scope The scope within the bucket to use. Depends on the selected bucket. Selectable from a list or manual entry.
Couchbase Collection The collection inside the scope where the document will be upserted. Depends on bucket and scope selection.
Document ID The unique identifier of the document to upsert. Must be provided as a string.
Document Value The JSON content of the document to be inserted or updated.

Output

The node outputs an array of JSON objects representing the result of the upsert operation. Each object contains:

  • id: The document ID used in the operation.
  • value: The JSON content of the document that was upserted.

Example output JSON:

[
  {
    "id": "my-document-ID",
    "value": {
      "field1": "value1",
      "field2": "value2"
    }
  }
]

No binary data output is produced by this operation.

Dependencies

  • Requires a valid connection to a Couchbase cluster, authenticated via an API key credential configured in n8n.
  • The node depends on the Couchbase SDK (couchbase npm package) for database interactions.
  • Proper permissions are needed for the specified bucket, scope, and collection to perform upsert operations.
  • The node uses utility functions to validate bucket, scope, and collection existence before performing operations.

Troubleshooting

  • Access errors: If the node throws an error about not being able to access the collection, verify that the bucket, scope, and collection names are correct and exist in the Couchbase cluster. Also, ensure the credentials have sufficient permissions.
  • Invalid JSON: Providing malformed JSON in the Document Value property can cause failures. Validate JSON syntax before input.
  • Document ID missing or empty: The Document ID must be provided and non-empty; otherwise, the operation will fail.
  • Connection issues: Errors connecting to Couchbase usually indicate misconfigured credentials or network problems.
  • Empty results: If no documents are found or affected, check that the document ID and collection are correct.

Links and References

Discussion