talha-asad / mongoose-url-slugs

Create URL compatiable slugs on mongoose models, ensuring uniqueness.
MIT License
40 stars 22 forks source link

Uniqueness Scope #12

Closed itsakap closed 8 years ago

itsakap commented 8 years ago

Is it possible to generate uniqueness within the scope of another field with this plugin? I want to generate slugs that are unique with respect to parent model. Thanks!

talha-asad commented 8 years ago

Can you give an example for this.

itsakap commented 8 years ago

User has many Articles, generate a slug for each Article that is unique with respect to its parent User (so two Articles may have identical slugs if they belong to two different Users). Does that make sense?

talha-asad commented 8 years ago

It does, so i guess its more like a prefix for the slug? So lets say we have Articles in different categories and each Article has a slug prefix for its category. I think that would make sense but how will you keep it dynamic ?

talha-asad commented 8 years ago

BTW i think what you are trying to do, you can already achieve by setting index_unique to false. And the plugin would allow more than one article to have the same slug. You can then query the Mongo with the additional user parameter.

talha-asad commented 8 years ago

If your problem is solved, please close this.