tags:

views:

112

answers:

1

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?

+2  A: 

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.

jhs