Sync Gateway - Integration to external system - Best way to track couchbase server changes?

Hi everyone. This is my first post here in the community forums, pleased to meet everybody.

I’m working on a custom integration to an external system. Basically, idea is we will have a custom connector that will bridge the gap between my external system and Sync Gateway. Something like this (i took this diagram from another thread somewhere):

External system is system of record. Couchbase Mobile is used as a mechanism to perform sync to/from mobile clients.

Changes can come both from my External System or from the CouchbaseLite clients, and should be synchronized either direction - 2 way sync between Couchbase and External system.

Changes from External System to Couchbase
I can push inserts, updates, deletes from External System into Couchbase through Sync Gateway using the “document” API endpoint (POST, PUT, DELETE, GET). So far so good. I have this working.

Changes from Couchbase to External System
Now, i need to be able to detect changes in Couchbase, and sync those changes to External System. Everything points to using the “_changes” feed for the “database” API endpoint. What i cannot figure out is how to filter out changes coming from external system itself. Say, a new record R1 is POSTed to Sync Gateway by my custom connector. Next time i download changes from _changes feed, that record R1 will be part of the feed (even though, technically, from the perspective of External System, it is irrelevant, as that change actually came from External System).

Is there a way to avoid that? Do i need to come up with my own mechanism to filter out those changes, to avoid “bounces” (change coming from External System is exposed in _changes feed to be consumed by…External System).

Am i going the right direction here?

Thanks for your kind help.

I think i found the solution. The _changes endpoint can be filtered like this:


Somehow i did not come across this filter querystring parameter in my travels in the couchbase documentation.

Good news is…it’s there, and it works.

At any rate, if anyone has a better suggestion, feel free to shoot.

1 Like

Thanks for the feedback and welcome to the Couchbase forums. Out of curiosity, where did you find the answer for this? You can file a docs ticket, too, straight from the documentation pages.

Hey! I found the answer for this originally on a youtube video where they were discussing about the channels feature. Upon more digging, i was also able to find this in the documentation, although, without the video, i don’t think i would have been able to join the dots properly…The documentation is a bit dry in that sense…

Here’s the documentation link. get__db___changes