Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update problem for mongoose pre save hooks #16

Open
berkkarahan opened this issue Mar 21, 2020 · 2 comments
Open

Update problem for mongoose pre save hooks #16

berkkarahan opened this issue Mar 21, 2020 · 2 comments

Comments

@berkkarahan
Copy link

berkkarahan commented Mar 21, 2020

Hey,
When updating a resource from admin panel, schema pre-hooks doesn't run.
However, when creating it, it runs perfectly.

This is the message at terminal in my express application,

(node:50219) DeprecationWarning: Mongoose: findOneAndUpdate() and findOneAndDelete() without the useFindAndModify option set to false are deprecated. See: https://mongoosejs.com/docs/deprecations.html#-findandmodify-

@Swarag-N
Copy link

it is actually a mongoose error , they are changing few libraries.
https://mongoosejs.com/docs/deprecations.html#findandmodify

add this part below the mongoose connections

//for  eprecationWarning: Mongoose: `findOneAndUpdate()` and `findOneAndDelete()` without the `useFindAndModify`
mongoose.set('useNewUrlParser', true);
mongoose.set('useFindAndModify', false);
mongoose.set('useCreateIndex', true);
mongoose.set('useUnifiedTopology', true);

@p-pcode
Copy link

p-pcode commented Nov 17, 2021

Hello @berkkarahan & @Swarag-N,
I am using admin-bro for one of my projects. The pre-hook/ post-hook isn't working for me. If I am making an API call, It triggers pre/post-hook, but it didn't work when clicking on save in admin-bro. Are you facing this problem @berkkarahan?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants