Understanding channels

Hi

i need a clarification about channels how to implement channels in my project.

based on my project the users have 4 roles may a user can act as 4 types of roles.

means a user can access doc by any one role.

clearly a user A can access a doc A as admin and User B can access the same doc as partner/agent
and user Z can access same doc as role user.

how can i implement this scenario by using channels

please reply quick.

and is there any step by step example for creating a channels is available please provide a link

Thanks

Hey @yafeearun,

Here are some great resources to learn more about channels:

https://developer.couchbase.com/documentation/mobile/current/guides/sync-gateway/channels/index.html

For your specific question, can you post the following:

  • A sample doc or set of docs that you are testing with
  • Your sync function
  • The relevant REST API calls you made to create users/roles and grant access to users/roles (if any)
  • The specific problem(s) you are running into … like “UserZ can write to DocA and should not be able to”

With a specific example, it will make it much easier to debug your issue.

Also, if the docs I posted aren’t making sense, please post specific feedback on what doesn’t make sense.

If you read through those docs and still have no idea how to implement it, then try to post a more complete specification of your problem – for example clearly differentiate between the read/write side of things, as well as the different doc types … assuming you have multiple doc types.

Hi @traun

my problem is i’m developing a loan management system with two interfaces like lenders and borrowers.both of them going to use the same application that means a single doc (loans ) is common to them but the usage is different .

i’m not yet using channels in my project. when i was refer the channels i was confused on following thoughts

#1 it’ll full fill my requirements?

#2 how it works?

based on the examples we declare channel attr in json and it have only one channel , based on my requirements both users can access the same doc when the switch a business

i’m using basic sync function right now

function (doc) {
channel (doc.channels);
}

A document can be assigned to multiple channels.

A few high-level options:

  • assign a doc to a single channel, and grant that channel to multiple roles
  • assign a doc to multiple channels, where each role is only granted one of the channels

Channels are extremely flexible. I’d be very surprised if it can’t match your use case. If you give a detailed description, I can give you a better sketch of a solution.