Hello, 
Thanks for response. I tried to apply what you suggested:

let's say that I didn't really create user accounts beside the Admin one i 
use to connect to admin couch server Interface and that I am trying to sync 
to a password protected Bucket + I have a shadow one too: {
    "interface": ":4984",
    "adminInterface": ":4985",
    "log": ["CRUD", "CRUD+", "HTTP", "HTTP+", "Access", "Cache", "Shadow", 
"Shadow+", "Changes", "Changes+"],
    "databases": {
        "showRoom": {
            "server": "http://myServer:8091";,
            "bucket": "sync_gateway",
            "sync": `function(doc, oldDoc) { 



  if (doc.type != "client" && 
            doc.type != "surveyAnswers") {

          // everyone can sync these documents
          channel("public");
        }
 if (doc.type == "client") {
            // Users can't assign their contact document to another user.
            if (oldDoc != null && oldDoc.userID != doc.userID) 
throw({forbidden: "Can't change userId."});            
            // Users can only change their own contact.
            requireUser(oldDoc == null ? doc.userID : oldDoc.userID);

        } else
     if (doc.type == "surveyAnswers") {
          // give user access to his survey Answers
          access(doc.userId, "survey-" + doc.userId);
          // add doc to user's  channel
          channel("surveyAnswer - " + doc.userId);

requireUser(doc.userId);
        }



}`,
            "users": {
                "GUEST": {
                    "disabled": true }
            },
            "shadow": {
                 "server": "http://myServer:8091";,
                 "bucket": "shadowDB"
            }
        }
    }
}

My questions are as follows:

Will this filter the sync making sure that only the profile  "client" of 
the current user will be updated & synced as for type == survey result?. 
How do I specify the password to access the bucket that is secured 
especially for the shadowing.

Sorry for long post. I am still new to this subject

Looking forward to your reply.

Le mercredi 11 mars 2015 16:22:48 UTC, Jens Alfke a écrit :
>
>
> On Mar 11, 2015, at 4:18 AM, Souhail Marghabi <[email protected] 
> <javascript:>> wrote:
>
> I am new to couchbase Mobile and I am developing an iOS app with couchbase 
> as a backend. I have a object called Survey which has another object called 
> "Profile" as an  attribute. When syncing I want to make sure that the 
> survey data gets only synced for the specific "profile" that applied change 
> to it. in  Other words how to make that we sync only and retrieve only the 
> related data for the current "profile" / user using the app.
>
>
> In the sync function:
> requireUser(doc.profile);
> channel(“profile-“ + doc.profile);
>
> The first line ensures that only the user named in the ‘profile’ property 
> can change the document.
> The second adds the document to a channel named after the profile. Then 
> you need to configure your user accounts so each has access to the channel 
> with the corresponding name, e.g. for user “foo” add “profile-foo” to the 
> admin_channels property.
>
> —Jens
>

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/85aa68a3-bc14-42d4-8331-9370dc47dabe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to