shard_ref.update("count", firebase.firestore.FieldValue.increment(1));
I am looking for way to increment and update in python, I am not abe to even update it with a predefined value in python. the doc doesn't specify any python samples.
I am using firebase_admin
sdk like this,
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
for more check docs https://firebase.google.com/docs/firestore/solutions/counters
Unfortunately (to me it just doesn't feel right), adding support for transforms in your codebase means you have to use google-cloud-firestore next to firebase_admin
.
You can then use Transforms such as Increment
, ArrayRemove
, etc.
Sample code:
from google.cloud.firestore_v1 import Increment
# assuming shard_ref is a firestore document reference
shard_ref.update({'count': Increment(1)})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With