In mongoose, Middlewares are also called as
Both of these middleware support pre and post hooks.
Its supported for document functions
Its supported for query functions
There are two types of Pre hooks
As the name suggests, Its executed in serial order i..e one after another
Parallel middleware offers more fine-grained flow control and the
hooked method is not executed until
done is called by all parallel middleware.
Post Middleware are executed after the
hooked method and all of its
pre middleware have been completed.
hooked methods are the functions supported by document middleware.
init, validate, save, remove