I've started prototyping some enhancements to support "subsetting" — syncing a subset of the server database to the device, but being able to pull more documents to the device as needed. These are on a branch of the iOS repo called
feature/subset. Please feel free to check it out and follow along :)
So far there are two new features:
1. A new replication property called "add_docs". It's a boolean that defaults to true, but setting it to false tells a pull replication to not create any docs locally — that is, it won't pull a doc from the server if there isn't already a doc with that ID in the local database. This feature will keep a subsetted database up to date, by pulling new revisions of the docs in the local subset without bringing in all of the available remote docs.
You enable it like this:
repl.customProperties = @{@"add_docs": @NO};
2. A new CBLReplication method -pullDocumentIDs:. It takes an array of strings and pulls the documents with those IDs from the server. (For obvious reasons this only works on a pull replication.) This method ignores filters and the add_docs property. There's not yet any progress information or error notification other than what's already available on the CBLReplication.
You can combine these features by creating an add_docs=NO pull replication at launch, and then calling -pullDocumentIDs: on it to load documents as you need them.
What's still missing:
- Making purge prevent the document from coming back when it's updated on the server. (An add_docs=NO replication won't re-add it, but a regular pull replication will.)
- Progress info for individual document pulls
- Being able to query the remote database to find documents to pull
- More…?
—Jens