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

Document unique_slug #5

Open
Blackbaud-SteveBrush opened this issue Aug 4, 2016 · 1 comment
Open

Document unique_slug #5

Blackbaud-SteveBrush opened this issue Aug 4, 2016 · 1 comment

Comments

@Blackbaud-SteveBrush
Copy link

First of all, thanks so much for this awesome plugin! We're using it on a project that implements discriminators and ran into a problem where specifying the slug as unique:true threw errors. For example, if you had a base schema named Car, and had two discriminator schemas named Volvo and Toyota. If I wanted to create a "model" of "Road Rager" for both Volvo and Toyota, but make sure the slug was "road-rager" for both (and not "road-rager-1" for the second instance), this would be impossible with simply adding unique:true to the slug field because Mongoose throws an error if two discriminator models share the same slug.

Thankfully (!), you already had a property in your source code that would allow for a unique slug, but not use Mongoose's own unique method. I'm simply asking that you document this feature since it would be extremely helpful for folks using discriminators, but still want the unique slug feature. Thanks again!

slug: {
    type: String,
    slug: "name",
    slug_padding_size: 1,
    unique_slug: true, // <-- works like a charm with discriminators :)
    // unique: true <-------- this throws an error if two discriminator models want the same slug!
}
@gelito
Copy link
Member

gelito commented Aug 9, 2016

Thanks for the comment!!

And yes, we must document it (our fault, being lazy! ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants