并不真地。
当您DELETE
记录时,CouchDB 会从中删除除_id
and之外的所有字段_rev
(当然,_deleted
也存在)。此信息也称为tombstone
.
当您只是添加_deleted: true
到文档时,它会被标记为已删除,但所有其他字段仍然存在:
http --json http://localhost:5984/recipes/SpaghettiWithMeatballs
:
HTTP/1.1 404 Object Not Found
Cache-Control: must-revalidate
Content-Length: 41
Content-Type: application/json
Date: Sat, 17 Aug 2013 14:49:17 GMT
Server: CouchDB/1.4.0+build.c843cef (Erlang OTP/R16B)
{
"error": "not_found",
"reason": "deleted"
}
http --json http://localhost:5984/recipes/SpaghettiWithMeatballs\?rev\=9-ac84157c2206793b7d142f5d8e2c97d0
:
HTTP/1.1 200 OK
Cache-Control: must-revalidate
Content-Length: 425
Content-Type: application/json
Date: Sat, 17 Aug 2013 14:48:55 GMT
ETag: "9-ac84157c2206793b7d142f5d8e2c97d0"
Server: CouchDB/1.4.0+build.c843cef (Erlang OTP/R16B)
{
"_attachments": {
"my_recipe.txt": {
"content_type": "text/plain",
"digest": "md5-198BPPNiT5fqlLxoYYbjBA==",
"length": 85,
"revpos": 2,
"stub": true
}
},
"_deleted": true,
"_id": "SpaghettiWithMeatballs",
"_rev": "9-ac84157c2206793b7d142f5d8e2c97d0",
"description": "An Italian-American dish that usually consists of spaghetti, tomato sauce and meatballs.",
"ingredients": [
"spaghetti",
"tomato sauce",
"meatballs"
],
"name": "Spaghetti with meatballs"
}
但是,在压缩过程中,该文档将被转换为tombstone
只有_id
,_rev
和_deleted
字段。在此之前,这是将数据保留在文档中以轻松撤消删除操作而无需请求文档的先前修订版的好技巧,因为所有内容都可用于最新版本。