Mongoose: kill pluralization

Created on 19 Feb 2013  Â·  11Comments  Â·  Source: Automattic/mongoose

Most helpful comment

I agree wholeheartedly, we're removing pluralization in the next backwards breaking release :+1: I hear your frustration, when I was first starting with mongoose I once spent 2 hours trying to figure out why no documents were saving (back before I knew about show collections) and found out that pluralization was saving to a collection that I didn't expect.

image

All 11 comments

I assume you mean for he collection name? Why kill this? The default now seems right to me, and there's an option to disable it.

Yep, but it shouldn't be the default b/c it confuses people all the time.

I'd like to take this on.
But how do you suggest turning it off, without breaking every installation ever?
First I believe the code should scream (like the driver did about the write concern in 1.1.1)
I can also write a tool that can will rename collections to non plural form.

I want to wait on this until 4.0

On Sunday, September 22, 2013, Refael Ackermann wrote:

I'd like to take this on.
But how do you suggest turning it off, without breaking every installation
ever?
First I believe the code should scream (like the driver did about the
write concern in 1.1.1)
I can also write a tool that can will rename collections to non plural
form.

—
Reply to this email directly or view it on GitHubhttps://github.com/LearnBoost/mongoose/issues/1350#issuecomment-24885905
.

Aaron
@aaronheckmann https://twitter.com/#!/aaronheckmann
soundcloud.com/ajhecky
github.com/aheckmann

We could introduce an option in the meantime. Defaulting it to on. I don't
want to auto rename anything.

Something like mongoose.set('pluralization', false) would be good.

On Sunday, September 22, 2013, Aaron Heckmann wrote:

I want to wait on this until 4.0

On Sunday, September 22, 2013, Refael Ackermann wrote:

I'd like to take this on.
But how do you suggest turning it off, without breaking every
installation ever?
First I believe the code should scream (like the driver did about the
write concern in 1.1.1)
I can also write a tool that can will rename collections to non plural
form.

—
Reply to this email directly or view it on GitHubhttps://github.com/LearnBoost/mongoose/issues/1350#issuecomment-24885905
.

Aaron
@aaronheckmann https://twitter.com/#!/aaronheckmann
soundcloud.com/ajhecky
github.com/aheckmann

Aaron
@aaronheckmann https://twitter.com/#!/aaronheckmann
soundcloud.com/ajhecky
github.com/aheckmann

Added it on the schema level

Also I want to be able to mongoose.set('pluralization', false) do you have an example of how to use mongoose.options?

P.S. The "rename-tool" will not run automatically, but could be called manually.

@aheckmann Regarding the move to kill auto pluralization in 4.0...

From my POV It makes sense to keep auto pluralization for the following reasons:

  1. Collection names are almost always plural
  2. REST typically follows plurality i.e. GET /users
  3. Without pluralization for say mongoose.model('user');, typing db.user.find() in the mongo shell would feel weird to me

I'm sure you're aware of those reasons. I thought I'd vote to keep auto pluralization :)

My two bits. Just drop the pluralization and lowercase requirement all together. Don't option it, that's stupid. Making a all lower case requirement is not being compliant with mongoDB

Think of this AND your next design choices like this:

  • by removing some unnecessary draconian rules in this world YOU ENABLE ME (US / YOUR USERS & FANS) TO BE THE MORE CREATIVE
  • AND it costs you LESS OF YOUR EFFORT
  • AND enabling my creativity you're BUILDING A BETTER PRODUCT
  • AND by creating and enforcing additional (and by not removing) arbitrary rules the LESS RELEVANT YOU BECOME TO YOU MARKET YOUR MARKET
    Just my two bits.
    Need help removing the .toLower() in your code on the collection name?
    If the application is structured well this is probably in only one line of code. So you can fix this in no more consideration that the next maintenance release.

Thanks.

I agree wholeheartedly, we're removing pluralization in the next backwards breaking release :+1: I hear your frustration, when I was first starting with mongoose I once spent 2 hours trying to figure out why no documents were saving (back before I knew about show collections) and found out that pluralization was saving to a collection that I didn't expect.

image

+1 for killing this. I was confused by this behavior long time ago too.

Should this be tagged as mongoose v6.0 and breaking-change?
This is a major breaking changes and if a developer just upgrade to 6.0 without renaming their collection name, all data will be missing in mongoose, we may need better warning on documentation.

@Fonger we thought about killing it, but upon further discussion we figured removing pluralization by default would cause more harm than good. All existing tutorials assume pluralization, and I don't think the benefit of removing pluralization by default is worth breaking most existing content and most projects that depend on mongoose.

Was this page helpful?
0 / 5 - 0 ratings