Ok I see why deleting using the sync gateway does not work. I've now tried
to delete it directly using the Couchbase Java SDK (wrapped into the ColdFusion
cfcouchbase library <https://www.ortussolutions.com/products/cfcouchbase>).
But for some reason I still seem to doing something wrong - as I get back
documents from the query but as soon as I try to delete them, Couchbase
returns the getStatus().getMessage() as 'Not Found'.
Can you please tell me, where I've done a locigal mistake?
*FYI: the couchbaseClient variable is a ColdFusion wrapper for the Java
Class com.couchbase.client.CouchbaseClient.*
This code is in my added view:
function(doc,meta){
if( !doc._deleted && doc.channels && doc.channels.length && doc.type !=
'Setting' ){
for( var i = 0; i < doc.channels.length; i++ ){
emit(doc.channels[i],doc);
}
}
}
This is saved with the following name (designDocumentName, viewName,
mapFunction):
couchbaseClient.asyncSaveView('channels','channel',... map function code
from above ...)
Then I'm querying this view using the following query (designDocumentName,
viewName, options):
couchbaseClient.query('channels','channel',{ key=arguments.channelId })
Last but not least: I'm looping over the result set and call the delete
function for the document.id:
<cfloop array="#local.docs#" item="local.doc" index="local.index">
<cfset future = couchbaseClient.delete(local.doc.id) />
<cfoutput>#future.getStatus().getMessage()#</cfoutput><cfabort> <!---
this outputs 'Not Found' ---->
</cfloop>
Am Montag, 23. November 2015 00:23:25 UTC+1 schrieb Jens Alfke:
>
>
> On Nov 22, 2015, at 11:41 AM, [email protected] <javascript:>
> wrote:
>
> And afterwards deleting every single document using the following request
> for each one:
>
> http://developer.couchbase.com/documentation/mobile/1.1.0/develop/references/sync-gateway/rest-api/document/delete---db---doc-/index.html
>
>
> Deleting a replicated doc adds a new ‘tombstone’ revision that marks the
> deletion. You don’t want that. (In a nutshell, this tombstone will be newer
> than your old revision you’re restoring, so it takes precedence over it.)
>
> What you want to do is *purge* the server-side doc; this literally
> deletes it and all its revisions from storage, causing the server to forget
> about it completely. The problem is that Sync Gateway currently doesn’t
> implement the _purge call, and even if it did, it would be a privileged
> call (part of the admin-only API) not something a client could use.
> What you’ll need to do is implement a bit of app-server code that can
> respond to an (authorized) request to purge a user’s docs, and will use a
> Couchbase Server ‘Delete' call to erase the document from the bucket, which
> is pretty much equivalent to a purge.
>
> —Jens
>
--
You received this message because you are subscribed to the Google Groups
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mobile-couchbase/bac2016c-fd9d-4f10-9bff-eb86e97891f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.