CouchbaseVectorDelete

Delete a vector document by its ID.

Syntax

couchbaseVectorDelete(cacheName, id)

Parameters

Parameter
Type
Required
Description

cacheName

String

Yes

Name of the cache configuration

id

String

Yes

Document ID to delete

Returns

Returns a boolean:

  • true - Document was successfully deleted

  • false - Document was not found (nothing to delete)

Examples

Basic Deletion

// Delete a vector document
deleted = couchbaseVectorDelete(
    cacheName = "default",
    id = "vec_12345"
);

if (deleted) {
    println("Document deleted");
} else {
    println("Document not found");
}

Delete with Confirmation

Delete User Document

Cleanup Old Documents

Batch Deletion

Delete Conversation History

Safe Deletion with Retry

Delete with Audit Log

Delete Article Chunks

Notes

  • Returns boolean - true if deleted, false if not found

  • No error on missing - Gracefully handles non-existent documents

  • Immediate effect - Document is deleted immediately (no undo)

  • Case sensitive - Document IDs are case-sensitive

  • No cascade - Does not delete related documents automatically

Error Handling

Best Practices

  • Check existence - Use couchbaseVectorGet() first if you need the data

  • Verify ownership - Check userId before deleting user documents

  • Batch operations - Delete multiple documents efficiently in loops

  • Audit trail - Log important deletions for compliance

  • Error handling - Always wrap in try/catch for production code

  • ⚠️ No undo - Deletion is permanent, consider soft-delete flags instead

Soft Delete Alternative

See Also

Last updated

Was this helpful?