title: How to model linked accounts like this in MongoDb?
body: <p>My application has both facebook and twitter users. Now users can merge two accounts together which means they can login with either facebook or twitter account. </p>
  
  <p>Right now, I have a model like this. </p>
  
  <pre>
  <code>
  { "_id" : ObjectId("51103a3e69931d2f03000001"), "email" : "email", "id" : "twitter_id", "token" : "token", "secret" : "secret"}
  
  { "_id" : ObjectId("51103a3e69931d2f03000001"), "email" : "email", "id" : "facebook_id", "token" : "token", "secret" : ""}
  </code>
  </pre>
  
  <p>Now if these two accounts are the same and the user decided to merge or connect one of his account to something else. How should I change this model effectively and performance as well. I am thinking of having another object called </p>
  
  <p><code>
  {"linked_ids" : ["facebook_id", "linkedin_id" ]}
  </code></p>
  
  <p>in both accounts. So, the data would be like this. Once merged.</p>
  
  <pre>
  <code>
  { "_id" : ObjectId("51103a3e69931d2f03000001"), "email" : "email", "id" : "twitter_id", "token" : "token", "secret" : "secret", "linked_id" : ["facebook_id"] }
  
  { "_id" : ObjectId("51103a3e69931d2f03000001"), "email" : "email", "id" : "facebook_id", "token" : "token", "secret" : "", "linked_id" : ["twitter_id"] }
  </code>
  </pre>
  
  <p>Not sure if this would be the best way for performance and scalability? </p>