What are Mongoose (Nodejs) pluralization rules?

前端 未结 3 1467
北恋
北恋 2020-12-18 20:12

I am a newbie to the Node.js, Mongoose and Expressjs. I have tried to create a table \"feedbackdata\" using the Mongoose in MongoDB via the following code. But it is created

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-18 20:45

    The pluralization rules is here to ensure a specific naming convention.

    The collection name should be plural, all lowercase and without spacing.

    What are naming conventions for MongoDB?


    I think you should ask yourself if you want to follow the main rule (ensured by mongoose as a default behavior) or get rid of it.

    What are the perks ? What are the good points ?

    You design first what is an user (User model) and then you store users into a collection. It totally make sense.

    Your call.


    If you ask yourself how to get the final name of the collection after the pluralization :

    const newName = mongoose.pluralize()('User');
    

提交回复
热议问题