> On Sep 29, 2014, at 5:25 AM, Thiago Alencar <[email protected]> wrote:
> 
> This document is newer, so I believe sync gateway will make this the winning 
> revision from the conflict

That's correct as long as by "newer" you mean "has more revisions" (i.e. higher 
generation count) There isn't any chronological timestamp on a document.

> After logging in, I first wait for the replication to complete, and just then 
> I call [database existingDocumentWithID], in the hope that now I'll get the 
> document instead of creating a new one.
> But no, I'm still not able to find the document and therefore I have no 
> access to the "blobData" generated from the first device.

Sounds like the document isn't in any channel your user account can read.

> And already to advance / confirm: right now I have basically nothing in my 
> sync function

The default sync function will assign the channels listed in the document's 
"channels" property. Since you didn't add such a property to your document, 
it's not in any channels. So unless you gave the user access to the wildcard 
"*" channel, the user won't be able to see the document, explaining your 
problem.

There are many ways to solve this, depending on your apps' goals. A simple one 
is:
Define a private channel for each user, named something like "user-" + username
When creating a user account, add that channel to their admin_channels property
When creating documents, add a "channels" property whose value is an array 
containing the user's channel

An even simpler one is to give every user account access to the "*" channel, 
although you'd only want that for experimentation, probably.

This isn't the first time new developers have run into this, and I'm realizing 
that it's a problem with the Gateway's default settings — they create a 
situation where you can't read your own writes, which is unexpected.

—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/4A6190C7-8DD1-43FA-975C-FE211597F1B6%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to