I’m using couchbase lite iOS v1.0.4, couchbase server enterprise v3.0.2, and sync gateway enterprise v1.1.0. If I have a list of document Ids I want to pull down from the server how do I get couchbase lite to request them from the server and retrieve the documents? If this isn’t possible then I could request the documents themselves in JSON format, but is there a way for me to store them with their existing ids and revs in the local couchbase lite db and have them pushed to the server on updates successfully?
The replication protocol supports this, but unfortunately it hasn’t been implemented in Sync Gateway yet (issue #545.)
You can get a document from Sync Gateway using a simple GET request (see the REST API docs.) Inserting it into your local CBL database is trickier because you have to preserve its existing revision ID (_rev
), but a normal putProperties
call will create a new revision with a new _rev
. The push replicator will then push that to the server and it’ll appear to be a conflict.
I don’t think the public native API exposes the method to insert an existing revision, because normally it’s only needed by the replicator. However, it is exposed in the Couchbase Lite REST API; you PUT
the revision as usual but set the URL query param ?new_edits=false
.