如何删除CouchDB中的多个文档? [英] How can I delete multiple documents in CouchDB?
问题描述
我要删除 foo
等于 x 的所有文档。似乎是一个非常基本的操作,但我无法弄清楚。
I want to delete all documents where foo
equals x. Seems like a pretty basic operation, but I just can't figure it out.
我知道如何删除单个文档,但这还不够好-我可能有一次删除几千个。
I know how to delete an individual document, but that's not good enough - I may have to delete a few thousand at a time.
如何批量删除CouchDB中的文档?
How do I bulk delete documents in CouchDB?
推荐答案
我不知道这是不是正确的方法,但是要创建一个显示 foo
字段的视图,并在视图中查询<$ c $您要删除的所有文档中的c> doc._id ,并针对所有文档进行批量更新。因此,两个(理想情况下)打电话到沙发上。
I don't know if it's the right way but make a view that exposes the foo
field, query the view for the doc._id
s of all your documents that you want to delete, and make a bulk update against all your documents. So two (ideally) calls to couch.
http://comments.gmane.org/gmane.comp.db.couchdb.user/11222
有
对要删除的所有文档进行批量更新,并更新 doc._deleted = true
遵循批量删除文档
Do a bulk update on all the documents you want to delete and update doc._deleted=true
following the example in Bulk deletion of documents
这篇关于如何删除CouchDB中的多个文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!