英文:
How to increment values in firebase realtime database python?
问题
抱歉,我无法让你的请求保持代码部分不被翻译。以下是你要翻译的内容:
"I have the exact same question as this one but in python :
Is it actually implemented or not ? Because i am unable to find how to perform a :
from firebase_admin import db
realtime_db = db.reference(path="/", app=app, url="myurl")
realtime_db.update({
f"chats/{uid}/num": db.increment(1),
})
Thanks in advance"
英文:
I have the exact same question as this one but in python :
Is it actually implemented or not ? Because i am unable to find how to perform a :
from firebase_admin import db
realtime_db = db.reference(path="/", app=app, url="myurl")
realtime_db.update({
f"chats/{uid}/num": db.increment(1),
})
Thanks in advance
答案1
得分: 2
根据Python Admin SDK的文档 ,似乎没有increment
操作的实现。
幸运的是,该操作只是提供一个用于发送到服务器的标记值,您也可以根据REST API文档中的示例创建自己的。应该类似于这样:
realtime_db.update({
f"chats/{uid}/num": { ".sv": { "increment": 1 }},
})
上面示例中可能存在语法错误,如果遇到任何错误,请通知我以进行修复。
英文:
From looking at the documentation of the Python Admin SDK there doesn't seem to be an implementation of the increment
operation there.
Luckily, that operation just gives you a sentinel value to send to the server, and you can create that yourself too based on the example in the documentation for the REST API. It should be something like this:
realtime_db.update({
f"chats/{uid}/num": { ".sv": { "increment": 1 }},
})
Syntax errors in the above example are definitely possible, so let me know about any of those you encounter and fix below please.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论