Skip to content

is it possible to do the same thing as $inc with other operator that supports runValidator? #10783

Answered by vkarpov15
siinghd asked this question in Q&A
Discussion options

You must be logged in to vote

$set is the only other option, or do find() then save() (potentially in a transaction if you're worried about race conditions). The reason why validators don't run on $inc is that Mongoose doesn't know the current value of verificationcount when it sends $inc.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Uzlopak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants