CouchbaseVectorDelete
Delete a vector document by its ID.
Syntax
couchbaseVectorDelete(cacheName, id)Parameters
cacheName
String
Yes
Name of the cache configuration
id
String
Yes
Document ID to delete
Returns
Returns a boolean:
true- Document was successfully deletedfalse- 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 -
trueif deleted,falseif not foundNo 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
Related Functions
couchbaseVectorAdd - Store vector document
couchbaseVectorGet - Retrieve vector document
couchbaseVectorList - List vector documents
couchbaseQuery - Delete with complex queries
See Also
Last updated
Was this helpful?
