Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting document attachments in CouchDb

Tags:

couchdb

In CouchDb's documentation, the described method of deleting document attachments is to send a DELETE call to the attachment's url.

However, I have noticed that if you edit the document and remove the attachment stub from the _attachment field, it will not be accessible anymore.

If i remove foo.txt from the document below and save to CouchDb it will be gone the next time I access the document:

{  
  "_id":"attachment_doc",  
  "_rev":1589456116,  
  "_attachments":  
  {  
    "foo.txt": 
    {  
        "stub":true,  
        "content_type":"text/plain",  
        "length":29  
    }  
  }  
}

Is the attachment actually deleted on disk or is just the reference to it deleted?

like image 827
henrik_lundgren Avatar asked May 01 '10 14:05

henrik_lundgren


1 Answers

The two methods are identical.

Whether you DELETE the attachment URL, or remove its stub from the document, the data is marked as deleted using the internal MVCC system. You might say the reference to it is deleted.

However, when you run compaction, the attachment will be deleted on disk.

like image 136
JasonSmith Avatar answered Oct 01 '22 07:10

JasonSmith