js
April 11, 2023, 11:09pm
1
Hello,
I am trying to purge the documents from a bucket using the Sync Gateway API, the endpoint response is a success, however, I am still seeing the documents in the bucket.
Sync Gateway configuration used for the bucket is shown in the screenshot attached.
Any idea why the documents are not getting purged?
bbrks
April 12, 2023, 1:31pm
2
The response shows which document IDs were purged based on the request - in your case it is showing that no purges happened.
Have you checked the document ID being passed in the request matches the one in the bucket? This will be case sensitive.
js
April 13, 2023, 12:50am
3
@bbrks
I am using the documentId as shown in the screenshot.
The document exists in the bucket and after executing the Sync Gateway purge endpoint, the document still exists.
Please can you let me know how to make this work.
Does any configuration need to be set on the bucket for the purge to work?
Also, does the ‘*’ in the payload means all the documents will be purged upon successful completion of the endpoint
{
"a_doc_id": [
"*"
]
}
Thanks
JS
bbrks
April 13, 2023, 9:28am
4
Your purge request format should be:
{
"Previoussales_0009128d-999f-4866-99a0-b52df4717ee8Q": ["*"],
"another_doc_id_here_if_you_want_to_purge_more_than_one": ["*"]
}
The star represents which revisions to remove (in this case, all revisions of the given document ID)
js
April 13, 2023, 3:15pm
5
@bbrks
Thanks, it is working after changing the request payload as mentioned by you.
Is there a way to purge all the documents and all its revision in a bucket?
or
Do we need to provide individual documentIds in the request payload?
Thanks
bbrks
April 20, 2023, 11:26am
6
You have to specify document IDs if purging through Sync Gateway.
You could investigate purging via Couchbase Server instead, if you’d like to completely empty your database.