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.
However, one thing the documentation says is this: Creating a sync function is a more flexible way to map documents to > channels. A sync function is a JavaScript function that takes a document > body as input and, based on the document content, decides what channels to > assign the document to. The sync function cannot reference any external > state and must return the same results every time it's called on the same > input. > 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. Maybe instead of calling it channel on the model, I call it "database_id" or something like that. Then the database_id is used as the channel name on the Sync Gateway. Perhaps the "database_id" along with a username property? I still need to figure out how authorization and managing user accounts works. Would something like that work? Thanks, Brendan On Thursday, November 5, 2015 at 3:56:04 PM UTC-7, Brendan Duddridge wrote: > > Oh I see. Sorry. My misunderstanding. > > I need to be able to create a channel for every database document, so I > was thinking that would be done on the client side. It's the client who > creates the database on their local device (with a unique identifier - e.g. > db-12abc987def2340cdg) and then I was thinking that channels would be the > way to separate the data for one database from another. A user can have as > many databases as they like on their devices and they would sync only the > documents from the channels they have access to. > > Rather than all their data in a single database, they can spread it out > across multiple client side databases. I'm just trying to figure out how to > setup sync for that architecture with Sync Gateway and Couchbase Server. > > Thanks, > > Brendan > > On Thursday, November 5, 2015 at 1:56:09 PM UTC-7, Jens Alfke wrote: >> >> >> On Nov 5, 2015, at 11:42 AM, Brendan Duddridge <[email protected]> wrote: >> >> There seems to be a channels property on CBLReplication used for >> filtering, but not on CBLDocument or CBLModel. >> >> >> Channels are really only a server-side concept. The replicator sends that >> channel list to the server via the _changes feed, and the filtering is done >> on the server. The channel assignments of documents are not downloaded by >> the replicator, so there’s nothing for local code to filter on. >> >> Is "channels" a keyword then for an NSArray property that I would add to >> my CBLModel subclass in order to facilitate assigning documents to channels? >> >> >> Document/channel assignments are done by the JavaScript “sync function” >> in Sync Gateway. The channels are used for access control and routing to >> clients. >> >> —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/fd48b1b7-29c5-42a4-8321-18655703b200%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
