I m looking to store the profile details of the users in my app like their date of birth, country, first name, last name, date on which they joined, location of their profile_pic etc. I am using mongoose in Expressjs app. I will also be storing the username and hashed password and if they have activated from their email address. I have a few questions that I am getting confused and not really sure what to do?
Should I store all the users in one mongoose model and have a column for activated to c if the user has activated from its email link or not OR Should I have two different tables and once the user has activated I move him from the unactivated table to activated table.
Second thing is want to know should i store the details of profile as columns in same model or create another model for the profile details using population. I am thinking this as these details have anything I need to query about. They are just basically for read and write. I dont query using those parameters. So I was thinking having them in a different model would be slight be better as always I would be querying for the username or password only. One other option I think possible is having them in sub documents.
I will also be storing user preferences of my app and I have the same prob as above.
Please help me as to what option should I choose. I have done a lot of reading but not sure as of now. Please help me with whats the standard thing to do and what would be better
Thanks
Yes, store all users in one mongoose model, with an activated field. That way you simplify some likely database queries, such as getting a list of all your users (activated or not) or checking whether a username has been taken.
You should also store the details of the profile as fields in the same model. If you don't query using those parameters, don't index them. Putting them as subdocuments, in my opinion, is not that useful, and it only makes sense if you plan on having sets of profile details (more than one) per user.