Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: configurable auto slug pluralization in the database #2836

Conversation

AlessioGr
Copy link
Member

@AlessioGr AlessioGr commented Jun 16, 2023

Fixes #2957

Description

  • I have read and understand the CONTRIBUTING.md document in this repository

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • I have added tests that prove my fix is effective or that my feature works
  • Existing test suite passes locally with my changes
  • I have made corresponding changes to the documentation

@AlessioGr AlessioGr changed the title fix: remove auto slug pluralization in the database feat: configurable auto slug pluralization in the database Jun 16, 2023
@AlessioGr AlessioGr marked this pull request as ready for review June 16, 2023 14:54
@richadr
Copy link
Contributor

richadr commented Jun 16, 2023

  • Instead of the general config, maybe it is a better idea to add this to collection config, and add an option there to control the underlying database collection/table name (allowing any name, rather than setting pluralization).
  • Also, should this not come with changes to the documentation?

@AlessioGr
Copy link
Member Author

AlessioGr commented Jun 16, 2023

  • Also, should this not come with changes to the documentation?

You're totally right, I've added those!

Instead of the general config, maybe it is a better idea to add this to collection config, and add an option there to control the underlying database collection/table name (allowing any name, rather than setting pluralization).

So by setting pluralization to false, it should take exactly what you've provided as a slug for the document name in the database. The reason I set it as a global option is because I didn't really see a use-case for making it a per-collection setting. Why would someone want to disable it for some collections, but enable it for others? They might as well just set it to disabled globally and manually use pluralized slugs for collections where they want it to be enabled.

One thing I'm hoping to do anyways (not decided yet!) is disabling pluralization by default globally in v2.0 as well. Just makes no sense to have that in the first place, in my opinion, it's confusing if the data is saved differently than what's specified in the slug. Pretty unexpected behavior.

@DanRibbens
Copy link
Contributor

  • Instead of the general config, maybe it is a better idea to add this to collection config, and add an option there to control the underlying database collection/table name (allowing any name, rather than setting pluralization).

I agree with this. I would rather see a collection name property that overrides the default slug-derived naming instead of a global setting that modifies how collections are named.

Copy link
Contributor

@DanRibbens DanRibbens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pluralizeSlugs we use "slug" for routing, not just mongoose collection naming. I don't think this property is the right approach.

@AlessioGr
Copy link
Member Author

Closed in favor of #3153

@AlessioGr AlessioGr closed this Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weird Collection Name Due to Mongoose utils.toCollectionName
3 participants