가능한 중복 :
나는 문서 값을 업데이트해야
In MongoDB, How to toggle a boolean field in one document with atomic operation?"토글"쿼리
, 그것을 "전환"
는컬렉션은 "코멘트"입니다 boolean 플래그 "isAdmin"을 가지는
주어진 의견 ID를 업데이트 할 예정이며 isAdmin이 true이고 viceversa 인 경우이를 false로 설정합니다.
그러나이 작동하지 않습니다
db.comments.update({ "id": "xxx" }, { $set: { isAdmin: $not isAdmin } });
올바른 구문은 무엇입니까?
이 도움이 될 : http://stackoverflow.com/questions/9459789/in-mongodb-how-to-toggle-a-boolean-field-in-one-document-with- 원자 작업 – DhruvPathak