Have you seen the Document conflicts FAQ <http://developer.couchbase.com/mobile/develop/guides/couchbase-lite/native-api/document/index.html#conflict-faq> ?
On Thu, Oct 30, 2014 at 4:29 PM, Dominique Legault <[email protected]> wrote: > I think I've got a little more details into the issue. > > The problem I'm facing is when I insert a document that has a conflict > with another users document. because the user that inserted the conflicting > document doesn't have access to the document they can't resolve the > conflict with the document. > > I'm not getting an error returned either. the couchbase lite db on the > android just keeps the conflicting document and nothing is returned that I > can parse to indicate an error to the user. > > I've recently changed the sync-gateway json to give access to deleted > documents, but I don't think it would resolve this particular issue I'm > having. > > here is an example. > > User A, inserts a document > { "_id" : "mydocument", "key": "value", "type": "mytype", "username": > "usera"} > > document is synced to sync gateway. > > User B, inserts document with same id > { "_id" : "mydocument", "key": "value", "type": "mytype", "username": > "userb"} > > > the document inserts in to the local db, but when it tries to sync to the > sync-gateway it rejects it because there is already a document with the > same id. > > I don't see anything show up in the User B changes feed. > if I render the view of the User B document it still exists until I log > out and delete db, then it's gone, when I log in and resync with the > gateway the document isn't there. > > here is an example sync-gateway function > function(doc, olddoc) { > var channelDelimiter = "@"; > if ( (olddoc != null && olddoc.type == "mytype" ) || (olddoc == null > && doc.type == "mytype") ) { > if (olddoc == null) { > if (!doc.username || !doc.key ) { > throw({forbidden: "Missing required properties"}); > } > channel(doc.type + channelDelimiter + doc.key); > access(doc.username, doc.type + channelDelimiter + doc.key); > } else { > if (doc._deleted) { > requireUser(olddoc.username); > channel(olddoc.type + channelDelimiter + olddoc.key); > access(olddoc.username, olddoc.type + channelDelimiter > + olddoc.key); > } else { > if (!doc.username || !doc.key ) { > throw({forbidden: "Missing required > properties"}); > } > if (olddoc.username != doc.username || olddoc.key != > doc.key){ > throw({forbidden: "unmutable properties"}); > } > requireUser(olddoc.username); > channel(doc.type + channelDelimiter + doc.key); > access(doc.username, doc.type + channelDelimiter + doc. > key); > } > } > } > ) > > What would be the correct way to resolve document id conflicts ? > Is there any way for the client to see if a document conflicted ? > > On Thursday, 30 October 2014 11:43:36 UTC-7, Jens Alfke wrote: >> >> >> On Oct 28, 2014, at 1:56 PM, Dominique Legault <[email protected]> >> wrote: >> >> I'm using phonegap with Android and I'm having an issue where I insert a >> document in my local database and the document already exists in the sync >> gateway by another user. The sync gateway doesn't pull the document because >> the user is not the owner of the document. >> >> >> Could you describe this in more detail, maybe with an example? I'm not >> sure exactly what situation you're describing. Thanks. >> >> —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/89aa2f73-cef4-4a41-a2e0-251e8e1d0534%40googlegroups.com > <https://groups.google.com/d/msgid/mobile-couchbase/89aa2f73-cef4-4a41-a2e0-251e8e1d0534%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- 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/CACSSHCGz5hVx1PzQpxp%2B%2BafoOsCDPVp-OMh3FOqkyYPEaSzwiA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
