Maybe it’ll help to explain what’s going on behind the scenes.
Internally, every document stores a couple of pieces of metadata:
- the set of channels it’s in
- a set of (user, channel) pairs, each of which declares that a user gets access to a channel
- a set of (role, channel) pairs with similar meanings.
All of that metadata is produced by the callbacks invoked by the sync function. And it’s updated every time the doc is updated.
The way a user’s access privileges are computed is to start with the ‘admin_channels’ property, i.e. the channels the user is specifically given access to, and then add in all of the channels granted by documents — all the channels in (user, channel) pairs where the user matches. (A role’s access privileges are computed the same way.) Finally all the channels accessible to all the users’ roles are added.
So basically, user/role X has access to channel C if any of these is true:
- channel C is in X's admin_channels property
- there is some document that declares a (X, C) pair
- X is a user and has a role R such that R has access to C by the rules above
Does that help?
—Jens