Channeling and change in authenticated user login

16 views
Skip to first unread message

parvez....@decurtis.com

unread,
Jun 12, 2017, 6:32:43 AM6/12/17
to Couchbase Mobile
For a chat iOS application using Couchbase lite with Couchbase server having support for channeling. The channeling is implemented such that two users doing chat will receive chat messages relevant to each other and not related to other users. For example for a three device system (D1, D2, D3) with logged in users U1, U2, U3. When user U1 (on device D1) chats with U2 (on device D2) then they receive chat messages as expected and both the devices contain data related to this chat. If now user U1 logs out and user U3 logged in on device D1 and start chatting with user U2. In this case what about the data which is already present on device D1 (related to chat between U1 and U2)? Will Couchbase lite automatically remove this data from device D1? The older data should be removed from device D1 since it is not as per the current channeling setup.

Thanks

James Nocentini

unread,
Jun 12, 2017, 6:59:59 AM6/12/17
to Couchbase Mobile
You should use different databases for each user. A common pattern is to use the username as the database name (U1, U2, U3). So when the user logs in, the app will open (or create) the database which contains the data specific to that user.

James 

parvez....@decurtis.com

unread,
Jun 12, 2017, 8:56:13 AM6/12/17
to Couchbase Mobile
If we maintain user wise database at iOS end then it will be a manual effort to remove databases related to other users that were previously logged in on that device, isn't it?

James Nocentini

unread,
Jun 12, 2017, 9:09:28 AM6/12/17
to Couchbase Mobile
Yes, it might be good to delete the local database of users who haven't logged in for a certain period of time (say 30 days for example). But you could also just delete the database on logout and when the user logs back in all the documents which this user has access to will be replicated again. It depends on how often you expect users to log in and out on the same device.

James
Reply all
Reply to author
Forward
0 new messages