Skip to content

Toggle boolean #1508

Answered by AL1L
ehsanonline asked this question in Q&A
Discussion options

You must be logged in to vote

I looked through the documentation and even tried some things and I can't find a specific operator or function to invert a boolean...

For now you can do a compaison against false which should do the trick

UPDATE user:asdf SET is_admin = (is_admin == false);

Something funny I found is this is also valid, but not as strict, but you could use it if is_admin might not be a boolean.

UPDATE user:asdf SET is_admin = (is_admin = false);

As a double == is a strict equals.

Also, the perentesis aren't required, but I think it makes the code easier to read.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ehsanonline
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