开发者

Deleting document attachments in CouchDb

In CouchDb's documentation, the described method of deleting document attachments is to send a DELETE call to the a开发者_开发技巧ttachment'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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜