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 enables interaction with a Couchbase database, specifically focusing on managing documents within specified buckets, scopes, and collections. The "Create" operation for the "Document" resource allows users to insert new JSON documents into a Couchbase collection. Users can either specify their own document ID or let the node generate a unique ID automatically.

Common scenarios where this node is beneficial include:

  • Adding new records or entries to a Couchbase database as part of an automated workflow.
  • Inserting configuration data, logs, or user-generated content into Couchbase.
  • Integrating Couchbase document creation into larger data processing pipelines.

Practical example:

  • Automatically creating a new user profile document in Couchbase when a form is submitted on a website, optionally specifying a custom document ID or letting the system generate one.

Properties

Name Meaning
Couchbase Bucket The target Couchbase bucket where the document will be created.
Couchbase Scope The scope within the bucket to use for the document.
Couchbase Collection The collection inside the scope where the document will be inserted.
Specify Document ID Boolean flag indicating whether to use a user-specified document ID (true) or auto-generate (false).
Document ID The ID to assign to the new document (required if "Specify Document ID" is true).
Document Value The JSON content of the document to create.

Output

The output is a JSON array containing objects representing the created documents. Each object includes:

  • id: The document ID used (either user-specified or auto-generated).
  • value: The JSON content of the created document.

Example output JSON structure:

[
  {
    "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 using credentials that include:
    • Connection string (e.g., Couchbase server URL)
    • Username
    • Password
  • The node uses the official Couchbase Node.js SDK to connect and perform operations.
  • The node expects the specified bucket, scope, and collection to exist in the Couchbase cluster.
  • n8n must have configured credentials for Couchbase API access.

Troubleshooting

  • Connection errors: If the node cannot connect to the Couchbase cluster, verify that the connection string, username, and password are correct, and that the Couchbase server is accessible and running.
  • Bucket/Scope/Collection not found: Ensure the specified bucket, scope, and collection exist in the Couchbase cluster. Selecting them from the provided lists helps avoid typos.
  • Document ID conflicts: When specifying a document ID manually, if a document with the same ID already exists, the insert operation will fail. Use upsert instead if overwriting is desired.
  • Invalid JSON in Document Value: The document content must be valid JSON. Invalid JSON will cause errors during insertion.
  • Timeouts or network issues: These may occur if the Couchbase server is unreachable or slow to respond. Check network connectivity and server health.

Common error messages:

  • "Could not connect to database: ..." — Indicates connection or authentication failure.
  • "Please select a bucket." or "Scope 'X' not found in bucket 'Y'." — Indicates missing or incorrect bucket/scope selection.
  • Insert operation errors due to duplicate document IDs.

Links and References

Discussion