talha-asad / mongoose-url-slugs

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

adding the ability to set a different hook to trigger the slug creation #29

Closed mtimofiiv closed 7 years ago

mtimofiiv commented 7 years ago

See https://github.com/mindblaze/mongoose-url-slugs/issues/28

Basically, if, for whatever reason, you need the slugger to run on a pre-save instead of pre-validate (say, for example, you skip validation in a particular spot but still need a slug), you can specify this when mounting the plugin to the schema:

Product.plugin(urlslugs('name', { onHook: 'save' }));
talha-asad commented 7 years ago

Thanks, merging.