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
Shannon Lal -
Jennifer May -
Jasmine Mae -
01yym -
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