You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have extended a schema. Both the parent and child schema have validators and pre/post save middleware. It seems that the child pre-save middleware is run even before the validators! This is a major issue, as in the pre-save one would expect the document to already be validated.
I just confirmed this with a clean install of mongoose and mongoose-schema-extend only.
The middleware & validation is run as follows:
CHILD - PRE SAVE
CHILD - PRE VALIDATE
PARENT - PRE VALIDATE
CHILD - VALIDATE
PARENT - VALIDATE
CHILD - POST VALIDATE
PARENT - POST VALIDATE
PARENT - PRE SAVE
CHILD - POST SAVE
PARENT - POST SAVE
Also, it seems that with all the other middleware, the child middleware is executed before the parent middleware. I'm not sure if this works in all cases, so the best would be to provide a toggle to change the order of these - if I wanted to run parent middleware first, and then child middleware, I should be able to do it.
The text was updated successfully, but these errors were encountered:
I have extended a schema. Both the parent and child schema have validators and pre/post save middleware. It seems that the child pre-save middleware is run even before the validators! This is a major issue, as in the pre-save one would expect the document to already be validated.
I just confirmed this with a clean install of mongoose and mongoose-schema-extend only.
The middleware & validation is run as follows:
Also, it seems that with all the other middleware, the child middleware is executed before the parent middleware. I'm not sure if this works in all cases, so the best would be to provide a toggle to change the order of these - if I wanted to run parent middleware first, and then child middleware, I should be able to do it.
The text was updated successfully, but these errors were encountered: