Doubt of document channel

35 views
Skip to first unread message

Victor Fernandez

unread,
Jun 1, 2015, 6:27:34 PM6/1/15
to mobile-c...@googlegroups.com
Hi
I'm having some troubles to make syncronization between Couchbase Lite iOS and Sync Gateway, I'm filtering by channels.
This metadata of a document will help explain me better:
 "channels": {
      "noexiste": null,
      "txm": {
        "seq": 5978,
        "rev": "1-aae23304cdee262c2ccb53c8dd80e0bd"
      },
      "txm2": {
        "seq": 5978,
        "rev": "1-aae23304cdee262c2ccb53c8dd80e0bd"
      }
    },
    "access": {
      "noexiste": {
        "noexiste": 5978
      }
   }

I'm filtering in the iOS side by channel "txm", but I am still having this document synchronized (it suppose that now is of the channel "noexiste").
Does anyone could give me a tip about what could be wrong?

Regards!

Jens Alfke

unread,
Jun 1, 2015, 6:52:32 PM6/1/15
to mobile-c...@googlegroups.com

On Jun 1, 2015, at 3:27 PM, Victor Fernandez <vfern...@txmglobal.com> wrote:

I'm filtering in the iOS side by channel "txm", but I am still having this document synchronized (it suppose that now is of the channel "noexiste").

What revision of the document do you have on the client? (How many revisions are there?)

—Jens

Victor Fernandez

unread,
Jun 1, 2015, 6:57:45 PM6/1/15
to mobile-c...@googlegroups.com
How can I check this? I'm doing an allDocumentsQuery from CBLDatabase and I have the last revision of the document. Nevertheless this document have only one revision.

Jens Alfke

unread,
Jun 1, 2015, 7:06:52 PM6/1/15
to mobile-c...@googlegroups.com
On Jun 1, 2015, at 3:57 PM, Victor Fernandez <vfern...@txmglobal.com> wrote:

How can I check this?

Get the document in the app and look at its “_rev” property.

I'm doing an allDocumentsQuery from CBLDatabase and I have the last revision of the document. Nevertheless this document have only one revision.

I think your doc has conflicts. According to the internal metadata you showed, the doc used to be in the “txm" and “txm2” channels but was removed as of revision 1-aae23304cdee262c2ccb53c8dd80e0bd. That implies that there’s an earlier revision that was in those channels. It must be a conflicting revision on another (deleted) branch, since it couldn’t have a generation number less than 1.

—Jens

Victor Fernandez

unread,
Jun 2, 2015, 11:51:58 AM6/2/15
to mobile-c...@googlegroups.com
Thank you Jens, let me provide you an overview of what I’m trying to do:
In my App, I have mainly two types of documents: lets call them “operative” docs, and “configuration” docs.
I need to synchronize all the configuration docs regardless of their date, but, for the operative docs, I need to discard old docs and synchronize only the earliest ones.
in a previous post (https://groups.google.com/forum/#!topic/mobile-couchbase/9iOm9Sk50FQ) you had suggested me that create a
channel by week but this approach, is not suitable for this purpose because it will discard my configuration documents.
So what I’m trying to do then, is to set an “oldChannel” (noExiste) to the old operative documents so that they are not visible to the mobile app any more. But then, if I’m understanding correctly, if I assign them to another channel, couchbase would set them as “in conflict” due to the fact that there’s still a  document version in an old branch, is this right?
Therefore my question would be if it is possible to set a new channel to a document and delete the previous branches, so that couchbase lite won’t see any old channel but the new one only. 
How can we do that?

Jens Alfke

unread,
Jun 2, 2015, 1:11:17 PM6/2/15
to mobile-c...@googlegroups.com
On Jun 2, 2015, at 8:51 AM, Victor Fernandez <vfern...@txmglobal.com> wrote:

So what I’m trying to do then, is to set an “oldChannel” (noExiste) to the old operative documents so that they are not visible to the mobile app any more.

Or you could just not assign them to any channel.

But then, if I’m understanding correctly, if I assign them to another channel, couchbase would set them as “in conflict” due to the fact that there’s still a  document version in an old branch, is this right?

I don’t think so. It’s the client (or whoever updates docs) that creates conflicts. The sync function can’t create a conflict because it doesn’t modify documents.

—Jens

Victor Fernandez

unread,
Jun 3, 2015, 10:52:24 AM6/3/15
to mobile-c...@googlegroups.com
I already tried to assign null channel to obsolete "operative" documents but I still having the same result, these documents are being synchronized because at one point they belonged to one channel. Is there a way to delete this branch? Or it's possible in the sync function to limit these documents? 

Jens Alfke

unread,
Jun 3, 2015, 5:53:15 PM6/3/15
to mobile-c...@googlegroups.com
On Jun 3, 2015, at 7:52 AM, Victor Fernandez <vfern...@txmglobal.com> wrote:

I already tried to assign null channel to obsolete "operative” documents

You don’t need to assign a channel at all, to remove the doc. If the sync function doesn’t call channel( ), the document won’t be assigned to any channels anymore. In other words, the document’s channels are reset on every call to the sync function.

but I still having the same result, these documents are being synchronized because at one point they belonged to one channel. 

Have you tried the troubleshooting tips in the docs? It would be useful to see for sure what channels the doc is in. You can also GET the doc with ‘?open_revs=all’ and the response will include a property showing all the active revisions, i.e. conflicts.

—Jens
Reply all
Reply to author
Forward
0 new messages