Delete multiple documents in CouchDB

I have a “best practice” question on CouchDB (I actually use TouchDB for the CouchDB port for iOS) when using the CouchCocoa environment.

I need to delete a bunch of documents that I receive through a request. I know 3 ways to do this:

1) put all documents in NSArray, then use [CouchDatabase deleteDocuments:]

2) for all query strings, calling the delete method, for example: for the CouchQueryRow * string in query.rows) [row.document DELETE];

3) create a query that emits the _id, _rev properties and adds the _deleted property, and then use the bulk update, for example: [couchDatabase putChanges:]

What is better performance? Is there a better way to do this?

+5
source share
1 answer

At the HTTP API level, the fastest way to do this is to run a single batch request, which provides the _idcurrent of _revall documents that need to be deleted.

Your task is to make sure that CouchCocoa really does this & mdash; I know that CouchCocoa will try to cache the _revdocuments it reads, so if you delete the documents you just read, it [CouchDatabase deleteDocuments:]should be enough, otherwise you will have to first [CouchDatabase getDocumentsWithIDs:].

, _rev, . [CouchDatabase putChanges:] . , , .

, , , .

+1

All Articles