Our example is users are creating large docs every few days, so let’s say 3 a week. A large account has access to the data of hundreds of users, so for one week that could be 300 documents. For all-time that could be tens of thousands of documents. We currently use channels and channel filtering on the client to handle this. (sync gateway 1.3.1, couchbase lite 1.4.1). Every doc is assigned a channel based on the userId of the user that owns it and the week it was created in. When a user logs in we only include the channels for the past week, the current week, and the next week, so that they aren’t downloading thousands of documents that could be months old. Of course this is for the case where a user has been using the app for a long time and then needs to log out and log back in or logs in on a new device for the first time. So we’re only trying to limit the initial download of data, we don’t care about it building up over time.
I don’t think a custom function could work for time-based document filtering, since based on the documentation of it a document is run once through the filter function when it is created, and if the filtering is done on the client side then won’t the client still download thousands of documents then filter them? So the initial login for a large client would be really slow?
Alternately we would love to be able to dynamically query or replicate docs from the database based on what the client is viewing. Our clients are actually only viewing the data for a single week and user at a time, which is a very small amount of data. Is there anyway with sync gateway 2.8 and couchbaselite 2.8 that we could replicate or download data based on a N1QL query or a single channel without restarting the entire replicator?