Mongoose: [Mongoose v5] Allow us to disable the pluralize part of models

Created on 28 Dec 2017  路  1Comment  路  Source: Automattic/mongoose

Do you want to request a feature or report a bug?
I'd like to request a feature.

What is the current behavior?
Making a model of a word that isn't pluralized will make the model pluralized

What is the expected behavior?
By default the model would respect the entered string, not pluralize it. This can break backward-compatibility TOO much, to the point of data being missing due to certain words being non-plural.

I'd love for this to be a toggleable option in the connect options.

Please mention your node.js, mongoose and MongoDB version.
Node.JS v8.9.1
Mongoose v5.0.0-rc
MongoDB v3.6.0

Most helpful comment

You can do this in 5.0.0-rc0:

mongoose.pluralize(null);

This will make mongoose not pluralize collection names at all, so mongoose.model('User', schema) will store documents in the 'User' collection.

We considered making this the default for 5.0.0-rc0 (see discussion on #5878) but decided against it because we didn't think we'd given enough notice.

>All comments

You can do this in 5.0.0-rc0:

mongoose.pluralize(null);

This will make mongoose not pluralize collection names at all, so mongoose.model('User', schema) will store documents in the 'User' collection.

We considered making this the default for 5.0.0-rc0 (see discussion on #5878) but decided against it because we didn't think we'd given enough notice.

Was this page helpful?
0 / 5 - 0 ratings