You can't retrieve the document in the pre
hook.
According to the documentation pre
is a query middleware and this
refers to the query and not the document being updated.
You can't retrieve the document in the pre
hook.
According to the documentation pre
is a query middleware and this
refers to the query and not the document being updated.
For further actions, you may consider blocking this person and/or reporting abuse
Matthias C. -
Mahmoud Ramadan -
thinkThroo -
James Moberg -
Top comments (2)
If we can't get the document in the pre hook then what is the purpose of pre hook?
There's a hack we can do is getQuery and we can use
mongoose.model('modelName')
and do find operation