3

I want to do Filter Replication in CouchbaseLite from remote server to mobile as I only want to update a particular document from server to device and vice versa.

But there is no Example for Filter Push and Pull for Couchbase Lite Android.I saw Grocery sync Example on Github but it performs complete pull and push replication.

Can some one please give me some example for filter pull and push replication or any other Example for Couch base Lite android except Grocery Sync Example.

1

2 Answers 2

2

You have several options for filtering .

On v1.4,

you can do filtered push by either

  • specifying the filter property on the Replication object to specify a filter function that you can apply on the replication
  • Specifying the docIds where you can specify the list of document ids to push

You can do a filtered Pull by either

  • Specifying the docIds where you specify the list of document ids to pull

  • Specifying the channels property to indicate which channels to pull

On v2.0,

you can do filtered push by

  • Specifying the documentIDs on the ReplicatorConfig. This is the list of document ids to push

You can do a filtered Pull by either

  • Specifying the documentIDs on the ReplicatorConfig. This is the list of document ids to pull

  • Specifying the channels property on ReplicatorConfig to indicate which channels to pull

0
Map<String, Object> map = new HashMap<>();
    map.put("document_name", "<required_document_name>");

    mPull = getDatabaseInstance(context).createPullReplication(createSyncURL(context));
    mPull.setContinuous(false);
    mPull.setFilterParams(map);
    mPull.start()
1
  • While this code snippet may solve the question, including an explanation helps to improve the quality of your response. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. Apr 6, 2018 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.