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:

  1. how should structure database schema?
  2. 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:

  1. a unique app generated id (could doc's id simplicity).
  2. 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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -