Flush bucket and sync gateway


working on:
CBL 2.0 beta
SGW 2.0 beta
CBS 5.1

If I flush a bucket it looses the sync gateway config too (the user info). Is there a better way to delete all documents except the SGW config?


You could XDCR bucket 1 to bucket 2 with a XDCR REGEX filter for keys that have “_sync” .
Then Flush Bucket 1 and Re-XDCR data back from Bucket 2 to Bucket 1.

1 Like


Can’t I just do

   var  queryRequest = new QueryRequest()
                       .Statement("DELETE FROM `{bucketName}` where db=$db")
                       .AddNamedParameter("db", bucketName) //all documents in bucket have the same db parameter and by coincidence the same as the bucketName
                       .Signature(false); //what is this for?
                        var result = bucket.Query<dynamic>(queryRequest);

Or won’t the SGW sync info get deleted?

Or maybe:

  .Statement("DELETE FROM `{bucketName}` where id NOT LIKE $sgwu")

I just, at that time, need the userinfo SGW to be present caus otherwise I can’t connect from CBL


I had the same trouble. I simply flushed my bucket, and restart sync gateway service, it created the users.



yeah but that means I need to restart it remotely every night… . I can’t seem to find the api for that

I can get the N1QL working… . It isn’t stated anywhere clearly: can it only be used if there is an index present? If I run bucket.Query<dynamic>(queryRequest); it is just empty

Ok, I understand.
I didn’t had the same use case. I’m testing on my computer, so no trouble to restart the service.

Hoping that some real experts on this forum will help you.