'mongoose post update hook triggered even no document is updated
when I use mongoose updateOne to update a document with its id and additional query for optimistic locking as below
Model.updateOne({_id,...additionalQueryForOptimisticLock},updates)
if there is a conflict write, it returns as expectation;:
{
acknowledged: true,
modifiedCount: 0,
upsertedId: null,
upsertedCount: 0,
matchedCount: 0
}
but I don't expect that it still trigger the post update hook, is it a bug? thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|