Limiting Initial pull

Hey guys,

We are using Sync Gateway channels as users to save user specific data.

Lets say user have data for 1 year, all the documents have “date_created” field.

On the reinstall/fresh install, How do I make pull request for last 3 months data?

I know we can create a View to filter data from local cblite, what I am trying is to save how much data is pulled from the server.

Thank a lot.

Cheers

These kind of relative-time queries are problematic in any map/reduce database, because the criterion you really want to search for (“created in the last three months”) relies on external state, in this case the current date/time.

In the case of Sync Gateway, docs are assigned to channels when they’re created or updated, so you can’t have a channel for “the last three months’ data” because docs would have to leave that channel even when they haven’t changed.

What I’d suggest is having a channel for each month. The sync function can parse the date_created and assign a channel name like “2014-06” or “2014-07”, etc.

Then the client can configure its pull replication to sync with the channels corresponding to the latest three months. Currently it would use “2014-06”, “2014-07”, “2014-08”.

—Jens