Best Practice for managing userprofile documents

43 views
Skip to first unread message

Karthik Rajagopalan

unread,
Apr 15, 2016, 10:54:18 PM4/15/16
to Couchbase Mobile
Hi Couchbase_Gurus,

I recently started using CBL in android and like to know the best practice for managing user-profile documents. Please find below the usecase -

1) Once a new user signup, we like to have a user-profile created for them with UUID as their email-id(username).  This will be written to CBL and kickstart a push replication to sync_gateway. At this point of time, we like to have a separate channel created for the user's profile to deal with sync_gateway. How should we handle it?

2) Once the user is signed in,  the user can enter into the user profile screen and edit some of the fields. What's the best approach to deal if the document has already been updated from different mobile? Should we make sure to pull first and then allow user to edit? How should we deal if the network connectivity is lost at this point of time? Should we just schedule a continuous pull and just write to CBL always?

-Karthik

Jens Alfke

unread,
Apr 17, 2016, 5:29:36 PM4/17/16
to mobile-c...@googlegroups.com
On Apr 15, 2016, at 7:54 PM, Karthik Rajagopalan <kar...@gmail.com> wrote:

1) Once a new user signup, we like to have a user-profile created for them with UUID as their email-id(username).  This will be written to CBL and kickstart a push replication to sync_gateway.

The usual way to do registration is that you create your own API on the server to handle registration requests, and the server-side handler for this talks to the Sync Gateway admin API to create the user account and (if you want) a user profile document. Then when the user logs into their new account the profile doc is already there.

At this point of time, we like to have a separate channel created for the user's profile to deal with sync_gateway. How should we handle it?

You don’t have to create channels. A channel comes into existence when a document is assigned to it. So just define what your channel names will look like, and have the sync function use that naming scheme when it calls channel().

2) Once the user is signed in,  the user can enter into the user profile screen and edit some of the fields. What's the best approach to deal if the document has already been updated from different mobile? Should we make sure to pull first and then allow user to edit?

Yes, you’d want to pull first. You don’t need everything, just some channel that contains the profile doc.

How should we deal if the network connectivity is lost at this point of time? Should we just schedule a continuous pull and just write to CBL always?

It’s unlikely that the network would go down right after registering, but in any case you’d want to start a pull replication and then wait for the user-profile document to appear in the database. You can either do this modally, or else let the app run but just disable any features that involve accessing the profile until it arrives.

—Jens

James Nocentini

unread,
Apr 17, 2016, 11:48:07 PM4/17/16
to Jens Alfke, mobile-c...@googlegroups.com
--
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 mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/4A431E8B-8B5E-459C-A52C-B5E54A9E83A4%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages