1

I have the exact same question as this one but in python :

How to increment values in Firebase Realtime Database (v9)

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

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Tom3652
  • 2,540
  • 3
  • 19
  • 45
  • 2
    It doesn't seem to exist in the [documentation](https://firebase.google.com/static/docs/reference/admin/python/firebase_admin.db). Maybe you could file an issue on [GitHub](https://github.com/firebase/firebase-admin-python). – Doug Stevenson Feb 17 '23 at 15:53
  • Thanks for confirming because i did look at the documentation and could not find it, i will raise an issue / feature request :) – Tom3652 Feb 17 '23 at 17:32

1 Answers1

2

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.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807