On Mar 25, 2014, at 11:36 AM, Stanley Iriele <[email protected]> wrote:

> What is the difference between filtered changes feed and sync gateway?. Are
> they that comparable?

The Sync Gateway has a notion called “channels”, which are sort of like tags 
that get applied to a document revision when it’s added to the database, by an 
app-supplied JS “sync function”.

Clients can then filter their pull replications by channel, by using the magic 
filter name “sync_gateway/bychannel” and a query parameter “channels” whose 
value is a comma-separated list of channel names. This works with CouchDB, 
Cloudant, PouchDB, etc. as well as Couchbase Lite.

The big difference from traditional filtered replication is that the _changes 
feed can filter by channels very efficiently. It doesn’t have to load (or call 
a JS function on) every revision; it’s got per-channel change indexes it can 
consult.

Channels are also used for access control. Every user account has a set of 
channels that it’s allowed to access, and it can’t read documents that aren’t 
tagged with one or more of its channels. This is the thing that lets you avoid 
having to create a database per user. Also, an unfiltered pull replication will 
automatically be limited to the set of the user’s channels, so if you ignore 
filters you get all the docs you’re allowed to see and nothing more.

(Hopefully this isn’t off-topic. I believe the Sync Gateway is a valid member 
of the CouchDB family of databases, albeit perhaps that red-headed cousin off 
in the corner…)

—Jens

Reply via email to