On Sep 30, 2015, at 10:09 AM, Yonah Forst 
<[email protected]<mailto:[email protected]>> wrote:

Does anyone know of a way to filter a sync_gateway pull replication by a 
timestamp on a document? e.g. only pull documents with a timestamp in the last 
30 minutes

There isn’t really a clean way to do that.

At first I tried with channels and a cronjob. I had a script checking for 
expired documents and setting the isExpired property to true. My sync function 
would check that property and assign it either the 'expired' channel or the 
'active' channel. The problem was that replications would still pull all 
revisions up until that document got moved to the 'expired' channel which 
defeated the purpose.

It sounds like you did this before you removed access to the ‘expired’ channel. 
In which case it wouldn’t have any effect on what clients download, since 
they’d still be able to access the docs whether or not they were expired.

But the problem was that I then lost the ability to filter pull replications by 
an arbitrary channel (even if the user had access to that document through a 
different channel) . (I can explain why that is needed)

You should still be able to do that. Users can have access to any channels 
other than ‘expired’. (In fact you don’t need to have an ‘expired’ channel at 
all. When a doc expires, the sync fn just doesn’t add it to any channels.)

I've read in the comments that replication channels are just a convenience that 
set/get the filter and query_params properties, which I'm guessing queries the 
sync_gateway/_view/channels view.

No, channels are a real thing that are deeply built into the Sync Gateway (and 
make up most of its complexity…)

What I think you read is that the API property Replication.channels is a 
convenience that just sets the replication’s underlying `filter` and 
`query_params` properties. That’s how the channel info is communicated to Sync 
Gateway, for compatibility with CouchDB and the pre-existing REST API.

—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/BAB71F78-8304-43DC-9784-A942650F65D7%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to