Toggle Boolean findOneAndUpdate #10099
Answered
by
vkarpov15
moomoolive
asked this question in
Q&A
-
Hey guys, Is it possible to toggle a boolean with "findOneAndUpdate"? Here's an example of what I mean: |
Beta Was this translation helpful? Give feedback.
Answered by
vkarpov15
Apr 14, 2021
Replies: 1 comment 1 reply
-
Not atomically, I think your best bet would be to make |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Uzlopak
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not atomically, I think your best bet would be to make
isCool
a number and use bitwise operators: https://docs.mongodb.com/manual/reference/operator/update/bit/#mongodb-update-up.-bit if you need to atomically toggle a boolean.