One way sync from mobile to server


#1

Hi,

I have been working on one particular solution where mobile will sync a document(one way) and here at sync gateway level, this document will be deleted(marking _deleted property true) after some processing thorough changes feed.

I don’t want mobile to worry about that what happened to document at server, (when I delete it increases rev )

In order to prevent this I am using

If(!doc.deleted)
{
// do nothing
}

However it is still creating conflicts at mobile side.

second I also tried import filter to prevent this. no luck.

Am i missing something on my understanding? Or is there any other way to do that?

Any help is greatly appreciated.


#2

Which way is your replication? (Mobile to SGW (push) or SHW to mobile (pull))

Not entirely sure of the sequence of events here. Did you remove a document directly on server and is it the case that you don’t want that to be synced to the mobile app?


#3

Thanks Priya for reaching out. We have both types of replications i.e. few types of document one way -> mobile to SGW(push) and few types of documents SGW to mobile (pull).

None of them are bi-directional.

Question that i had before was -> For only One way -> mobile to SGW(push) I wanted to prevent this to reflect back at mobile. Since this would be one way push, Mobile should not be worried about if document is updated at server side. right?

However, Every time i make update at server side(In this case, I am marking as deleted), Mobile is failing to push new document, because of conflicts.

in order to prevent this behavior,I need help to modify sync function or some settings which could help mobile to keep pushing new documents without conflicts and without worrying about server side.(I don’t want to sync back to mobile for this few document type)


#4

@priya.rajagopal - Just reminder! I am waiting for your response.


#5

Which version of Sync Gateway are you using ? If you are on Sync Gateway 2.0 and you don’t want some documents on server to be synced over to the mobile clients then you can use the import-filter filter out documents you don’t want synced

Example:

"import_filter": `
        function(doc) {
           if (doc._deleted == true ) {
	      return true;
        }
       // docs of type foo are not synced 
           if (doc.type == "foo" ) {
             return false;
           } 
         
          return true;
        }
        `