I read all the documentation, and nothing help me to understand how I can make it work. 
You already said that the server cannot know the user of the application !!! 
The function look like
function (doc, oldDoc) {
…
access(username, channelname)
…
}
So username don’t come from the call and not from the application, but from the authentification to connect to sync !
Do I have to have a specific authentification for each users of the application ? 
Once again, there is something wrong about the documentations where users of couchbase is not users of the mobile application !
And I read that doc must contains doc.members, so any members, like new member have to be in the list to read the doc !

I want a complete sample that show how everything work with :
. a database
. a unique authentification to connect to the database ( to sync )
. multiple users in 4 categories : admin, shop, buyers
. A list of products, and orders
Grant :
. admin can access to all
. shop : create an account, create products, access to their commands
. product : read by buyers, complete access from shop owner
. buyers : access to product, and create orders
. orders : create by one buyers, for one shop
The process : someone open the application, fill a form, and chose to be a shop or a buyer.
If it’s a shop, he can create product, he can’t see products and orders from other shop, neither buyers
If it’s a buyer, he can create order, he can see only products and his own orders
This is an example that is almost my project, and you can see that the rules of synchronisation have to be very intelligent. The user of the application do not have authentification in couchbase server, he can’t have “role” so he can’t be affect to a channel… 
Show me a real project that show me that working, and I will be happy
.