YuriGor / mongoose-slug-updater

Schema-based slug plugin for Mongoose - single/compound - unique over collection/group - nested docs/arrays - relative/abs paths - sync on change: create/save/update/updateOne/updateMany/findOneAndUpdate tracked - $set operator - counter/shortId
MIT License
40 stars 13 forks source link

Manual overriding of slug #16

Closed ZeldOcarina closed 4 years ago

ZeldOcarina commented 4 years ago

Hello Yuri!

I am trying to setup a field to enable overriding of slug but can't quite find a hook to do so.

Mongoose findOneAndUpdate({ slug }) doesn't work as probably the plugin runs after Mongoose did its job.

I've searched through the documentation but could not find this feature.

I am handling by manually changing slugs on Atlas but it's definitely not an optimal setup.

Is it possible to achieve this in any other way?

Thanks! :)

YuriGor commented 4 years ago

Hi, you probably want this https://github.com/YuriGor/mongoose-slug-updater/blob/master/README.md#updating-slug-or-keeping-it-permanent It's possible to configure plugin which exactly events should it track.

ZeldOcarina commented 4 years ago

Yes this handles sorry I could not find it! 😅