if I sort the userIDs before generating the custom documentID for the document then I think it will create same documentIDs on both devices (in offline mode), for example userids as 100 & 200, we can create a documentID as DOCID:100:200 after sorting the ids in descending order. I think even if we create document with this approach on two devices still then Couchbase lite can handle the conflicts resulting from sync (when in online mode), correct?
On Friday, August 25, 2017 at 9:40:50 PM UTC+5:30, Jens Alfke wrote: > > > > On Aug 24, 2017, at 11:12 AM, [email protected] <javascript:> wrote: > > Is it possible to write logic in sync function on sync gateway such that > it will check the incoming documents and based on type will re-assign a > documentt ID to the document such as DOC::user1:user2 so both documents > from user1 and user2 can be merged into a single document and gets updated > back to both of the devices. > > > I'm not sure I'm understanding what you want. But document IDs are > immutable. Changing the document ID isn't possible because it would result > in a different document. > > If two users will be editing the same document, they need to both know the > ID of that document. You could consider defining its ID as a function of > the two users' IDs, i.e. "shared-between-$A-$B" where $A and $B are the two > user IDs. (To make this independent of which user is A and which B, you > should choose A as the ID thats sorts lower, i.e. min(user1,user2), and B > as the one that sorts higher.) > > —Jens > -- You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/3e4939f4-2416-4adf-ae72-6b315996ba06%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
