Sync Gateway. Add the channel to the document via Admin REST API


#1

In my application complex logic. There are one to many relationship.
How can I add a channel to the document via Admin REST API? I do not really understand how I can use this function sync, because the document belongs to the channel based on fairly complex logic. Just when assigning a channel to the document, you need to add a channel other documents.


#2

Looks like this question was also asked in a Github issue: https://github.com/couchbase/sync_gateway/issues/802
In the future, please avoid opening a github issue and forum thread at the same time.

Thanks
James


Document local update vs Channel added(Server) to same document update
#3

[quote=“Art, post:1, topic:3618”]
How can I add a channel to the document via Admin REST API?[/quote]

You can’t; documents can only be added to channels when they are updated since the channel assignment is part of the revision. The sync function runs while the revision is being added to the database, so it can assign channels.

the document belongs to the channel based on fairly complex logic. Just when assigning a channel to the document, you need to add a channel other documents.

You’ll need to find another way to do it, then. You may be thinking about the problem in ways that make sense for a relational database but don’t make sense for Couchbase Mobile.


#4

It is illogical …
If we have a server application that creates users and can add / edit a document via REST API, why make the logic of an add channel to document to another entity (sync function)? In fact, the addition of the channel to the document does not apply to most of synchronization, it is the business logic.
In making this logic in sync function is impossible to create, and even more difficult to develop an application Todolite (sample application) …
Maybe there is a way to assign a channel to the document from the server application?
The documentation is a description of one-to-many relationship. And, this is realized by using Couchbase rather than a relational database. I know that on the basis of a document-oriented databases can build complex applications without the use of relational databases. This is mathematics.
If I can run complex logic add the channel to the document sync function, why the same logic can not be run through the REST API?


#5

“You can’t; documents can only be added to channels when they are updated since the channel assignment is part of the revision. The sync function runs while the revision is being added to the database, so it can assign channels.”
(I do not understand how can a quotation mark)

Ok, but can you assign channels to update the document - update creates a new revision, when creating a revision updated channels.
Update the document possible through the Rest API. Or am I wrong?
This, of course, too workaround, but as far as I understood, the design mistakes were made, which are not easy to get around by …

“You’ll need to find another way to do it, then. You may be thinking about the problem in ways that make sense for a relational database but don’t make sense for Couchbase Mobile.”

Relationships can be implemented and using Couchbase. Look at the documentation, there are described scenario implementation.