'MongoDB Database Design For User Info Storage

So, I'm making a wiki-like website/app. So, originally I was thinking of making a new collection per user. Now, since this is a public wiki-like database, I want to ensure it could be scaled for millions of users, is this a good design choice for such a database, or is making a single collection and then storing each user as a new document instead of a new collection a better idea?

Also, what would be the best algorithm for checking if the password and username/email is correct? The only three I can think of are looping through every user, which would be extremely inefficient, somehow checking if the document contains those two values without iterating through every document/collection (this one would probably only be applicable if I didn't make a new collection per user, and instead stored all in one collection), and the third would be for the user's ID (which I use right now as the name of the collection) to be a hash of their username and password, and then simply get the collection via that hash, and check if it exists. Which one would be the best, and do you have any other more efficient algorithms?

If I were to use a new document per user instead of a collection, then the best solution would probably be to find a document with that password and username.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source