talha-asad / mongoose-url-slugs

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

doc.get is not a function with onHook: 'update' #30

Closed dortamiguel closed 7 years ago

dortamiguel commented 7 years ago

When I set the onHook to update I get the following error:

doc.get is not a function
talha-asad commented 7 years ago

Please provide with a reproduction.

dortamiguel commented 7 years ago

I'm using this framework that generates api rest.

When using the post method mongoose called the code inside the schema.pre.('save', function(){}) but with method post save is not called, instead it calls update so the slug was not being generated.

So I solved this issue making this plugin https://github.com/ellipticaldoor/slugify-mongoose