During the run of the project, it was always curious how the newly registered user was inserted into the MongoDB database. View Source discovery was originally through the mongoose to work with MongoDB. The mongoose is created by the model to create the corresponding collection in MongoDB, so that you pass the following code:
mongoose.model(‘User‘, UserSchema);
When creating a collection in the corresponding database, the first reaction will certainly infer that a ' User ' collection, but the fact is completely different from inference, which is the problem that has been bothering me for two, I tried to find my newly-built collection in the command line of MongoDB, the code is as follows
show collections //只能看到有一个名为users的collection,而没有User的collection
From this we can infer that mongoose the collection name we passed when we created the collection internally, and if there is no letter--s after the lowercase name, add a s after it, for the collection we just built, Will be named: Users.
"Mongodb"---scheme and collections correspondence problem