Lowercase names: this avoids case sensitivity issues, as MongoDB collection names are case sensitive.
Plural: more obvious to label a collection of something as the plural, e.g. "files" rather than "file"
No word separators: Avoids issues where different people (incorrectly) separate words (username <-> user_name, first_name <-> firstname). This one is up for debate according to a few people around here, but provided the argument is isolated to collection names I don't think it should be ;) If you find yourself improving the readability of your collection name by adding underscores or camelCasing your collection name is probably too long or should use periods as appropriate which is the standard for collection categorization.
Dot notation for higher detail collections: Gives some indication to how collections are related. For example, you can be reasonably sure you could delete "users.pagevisits" if you deleted "users", provided the people that designed the schema did a good job ;)
Examples:
users
pagevisits
users.pagevisits
Field name conventions (should) follow some of the same logic although camel casing those is fairly common.
begin with the system. prefix. (Reserved for internal use.)
However, if you follow the rule and create a collection with '_' as the beginning letter, such as "_TWII", you will encounter trouble when you want to drop the collection. See the test below and the way to fix it. Collection '_TWII' was created under 'people' db.
> show collections
_TWII
employees
system.indexes
> db._TWII.drop()
2015-02-19T16:34:56.738-0800 TypeError: Cannot call method 'drop' of undefined
> use admin
switched to db admin
> db.runCommand({renameCollection:"people._TWII",to:"people.TWII"})
{ "ok" : 1 }
> use people
switched to db people
> show collections
TWII
employees
system.indexes
> db.TWII.drop()
true
> show collections
employees
system.indexes
>
A short-cut to delete _TWII collection while under 'people' db:
MongoDB has some naming conventions. One of them is that database name are case insensitive. Also, mongo will plural your collection name if not specified. "course" will become "courses".
Since database names are case insensitive in MongoDB, database names
cannot differ only by the case of the characters.
Because of them, try to name all your collection in lowercase and without special characters. You'll avoid a lot of error - especially if you use Mongoose. Mongoose has some weird querying specificities.
For example, if you have a collection named "courses", here's how you need to structure your model: