MongoosefindOneAndUpdate accepts several options including new and rawResult.
Used alone, these options return the document as expect. Used together however, not the document is returned and used in the plugin callbacks but an object of this format
As one can see the wanted document is contained inside the value property.
I don't know if this can happen in more than the findOneAndUpdate query. And tbh I'm not in the mood to search the code for possible places it can happen.
IMHO this fix can be included as is since the probability that anybody will ran into a similiar issue is low enough.
Hey @codepunkt ! Hope you are well 😄 (#69)
Mongoose
findOneAndUpdate
accepts several options includingnew
andrawResult
. Used alone, these options return the document as expect. Used together however, not the document is returned and used in the plugin callbacks but an object of this formatAs one can see the wanted document is contained inside the
value
property.I don't know if this can happen in more than the
findOneAndUpdate
query. And tbh I'm not in the mood to search the code for possible places it can happen. IMHO this fix can be included as is since the probability that anybody will ran into a similiar issue is low enough.