Minimize the amount of data synced down to devices

I’m working on a file sharing service which will grow it’s file limit to thousands of documents.

With couchbaseLite and couchbase is there a way to limit the synchronization(pull) to a certain limit.?

There could be storage issues if the client device get synced with the entire dataset of the couchbase server.

@ag

Sync Gateway support the concept of channels which allows you to shard the documents in a DB so that users only receive the subset that is of specific interest to them.

Here is an introduction to channels:

https://developer.couchbase.com/documentation/mobile/1.4/guides/sync-gateway/channels/index.html

@andy

Thanks for the response.

Yes. Actually I wanted to ask, what if the users own data grows beyond a certain threshold (ex: location history GPS coordinates taken at certain interval) syncing the whole data set would not be ideal in that case. Is there a way to sync only a selected subset of data; and bypass sync gateway and talk to couchbase server for other parts of the data?

The filtered replication is supported please look at the following link :- https://developer.couchbase.com/documentation/mobile/current/guides/couchbase-lite/native-api/replication/index.html#filtered-replications

Bypassing sync gateway will confuse the sync gateway and its not recommended. If a document goes through sync gateway then it adds some meta data which allows sync to happen. If you change data directly on the server guarantee of sync is not available.

For something like time-series data that grows indefinitely, one way to treat it is to cycle through channels. So, for example, you could have monthly channels (May.2017, June.2017) and update a clients access on a regular basis. Combine that with purging older data.

Does that fit with what you have in mind? I think you were suggesting you’d write the time series data straight to Couchbase Server. If you don’t care about mobile clients receiving that data back, you could, although you can get the same effect by allowing a client to write to a channel they can’t read. (That’s a trick that isn’t obvious. Just because a client writes a document, doesn’t mean it automatically can read it back. See this blog post for a discussion.)