Kubide / mongoose-slug-generator

MIT License
30 stars 16 forks source link

Unique slug for Compound indexes #7

Open nicky-lenaers opened 7 years ago

nicky-lenaers commented 7 years ago

Hi,

I came across a case in my project where I would like to generate a unique slug, so I used your plugin. However, I'd like to have a unique slug per user, in other word, a Mongoose Compound Index (see here). For example:

/user-1/project-1 /user-2/project-1

should both the valid, even though the project-1 is generated using the unique slug generator. Would it be possible to implement this in your plugin?

Thanks!

rickogden commented 7 years ago

I have added this feature on my own fork of this project by adding a uniqueGroup option: https://github.com/rickogden/mongoose-slug-generator

YuriGor commented 6 years ago

@rickogden you may be interested in fixing your uniqueGroup feature, it doesn't work correctly in some cases:

watcher fields list should be updated by fields from uniqueGroup like I did it here And here is how I check if we can keep old shortId

rickogden commented 6 years ago

Hi @YuriGor,

Thanks for pointing this out to me. Unfortunately I don't have the time to update this at the moment and I no longer have any projects which use it. Please feel free to submit a PR though!

YuriGor commented 6 years ago

My fork moved too far from original so PR will be too painful) With this notification I just wanted to thank you @rickogden for the useful feature I merged and fixed then, so if you don't need it anymore - it's ok.