"Mongodb"---scheme and collections correspondence problem

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.