Thanks Jens. That's good to know. But doesn't that also mean that a user could theoretically alter the document (say, outside the app with a database editing app such as SQLIteManager) and affect where that document gets synced to?
For example, say a username field is used to assign documents to channels and a user edits the document JSON directly to change the username to "fred" even though he's "steve" and then that document gets assigned to the "fred" channel. Fred then downloads that document to their device because Steve buggered up the document's username property? Or is there protection in place to prevent a user from syncing documents that are outside of the list of channels they are assigned to? Thanks, Brendan On Thursday, November 5, 2015 at 10:24:22 PM UTC-7, Jens Alfke wrote: > > > On Nov 5, 2015, at 9:01 PM, Brendan Duddridge <[email protected] > <javascript:>> wrote: > > I was confused because the channels documentation mentions setting the > channels property on the document itself. I didn't know this had to be done > on the gateway. > > > Thats referring to the default sync function that you get if you don’t > specify any in the SG config. It operates by just looking at a “channels” > property in the document and assigning the doc to those channels. This > function literally just consists of > function(doc) { channel(doc.channels); } > So yeah, one very simple way of assigning channels is by having a property > in the document that explicitly lists the channels to assign the document > to. > > So that leads me to believe that maybe I do need to set a property on my > model object that can then be used to assign the document to the channel on > the Sync Gateway. > > > In a sense, the document *has* to contain the information on what > channels to assign it to, because the sync function isn’t allowed to > consult any external state, just the document. > > —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/95f58159-f9e5-4017-9bf5-76895861ca4b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
