mercredi 31 décembre 2014

Separate login for user / administrators using mongodb


I have 2 separate groups of users on my website. One is user and the other one is admin. Currently I put them in 2 different collections user and admin and login respectively. My questions is:




  1. Mongodb generates _id automatically for both user and the admin collection. Since they're in 2 different collections chances are one day you created one user and one admin with the same _id right? So it seems the only way is to check all documents in both dbs and make sure your newly created user (or admin) does not have repeated _id right? Is there something I can do natively in mongodb to make this happen without checking?




  2. I can also put all users and admins in one collection. This way I don't have a problem but I am not sure if I should do this.




p.s: because I have a table keeping track of user / admin balances so I certainly don't want the _id to repeat p.s2: the db is taking longer and longer to query. Also my ORM creates user instances and generated _id automatically for me. I am not sure if I should just generate an _id and create it this way...


Any comments are greatly appreciated. Thanks!!





Aucun commentaire:

Enregistrer un commentaire