mongodb - Database Scheme for unified profiles fetched from multiple Social Networks (Facebook and Linkedin...) -
the application i'm building allows users login using both facebook , linkedin accounts in order fetch friend these networks. each of friend can user of application.
i have couple of problems solve:
- how should structure database schema?
- how unify profiles?
potential solutions
regarding structure:
i'm using mongo (but open suggestions). though i'd create collection
of users
each user document looks this:
user = { appid: <id>, connections: [userid] }
so, each user has:
- a unique app generated id (could doc's id simplicity).
- an array of user's ids. ids of friend's profiles created in app.
regarding unifying profiles:
should unify users based on email or name? or both?
misc
i though use loginradius using singly that, , decided kill service. in other words, don't want depend on third party tool because core feature.
var userschema = new schema({ name: { type: string, default: '' }, email: { type: string, default: '' }, provider: { type: string, default: '' }, hashed_password: { type: string, default: '' }, salt: { type: string, default: '' }, authtoken: { type: string, default: '' }, facebook: {}, linkedin: {} })
i'm using schema mentioned above users collection.
and when new user wants sign up, using either local strategy or social strategies
i use update mongoose function "upsert: true" option, either update or
create entry.
Comments
Post a Comment