如何在 JavaScript 中切换布尔参数?
我想切换一个称为“会话”的值,然后更新此值。
我尝试进行session =!session,但这无效。 会话是对象内部的一个参数,该对象显示在我的NOSQL数据库中,我正在使用Firebase中的实时数据库。
但是会话:true和session:false Works
obs:obs:英语不是我的第一个lenguage,对不起,很抱歉如果我使用错误的单词。
I want to toggle a value called 'session' and then, update this value.
i've tried to do session=!session, but that didn't work.
session is a parameter inside a object, this object are displayed on my nosql database, i'm using the realtime database from firebase.
however session:true and session:false works
obs: English isn't my first lenguage, so sorry if I used wrong words.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

由于您想要根据现有值将值写入路径,因此您需要 使用事务。
像这样的东西:
Since you want to write a value to a path based on its existing value, you'll want to use a transaction.
Something like: