Hello,
I have noticed new feature FieldValue.increment() in the latest Firestore SDK for JavaScript
is it possible to add this feature in google-cloud-firestore?
Many thanks!
Seems like this is addressed with google-cloud-firestore 1.2.0
@GuanacoDevs Yes, the feature was added in #7989.
@tseaver - Could you explain how you use this?
u'test_col': firestore.FieldValue.increment(1)
AttributeError: module 'google.cloud.firestore' has no attribute 'FieldValue'
@binojohnthomas It looks like the google.cloud.firestore shim module needs updating (I would recommend not using it myself). Instead, use the firestore_v1 package:
```python
from google.cloud import firestore_v1 as firestore
````
I have opened #8173 to track updating the shim module.
@binojohnthomas as a temp solution you can use this way:
from google.cloud.firestore_v1 import Increment
db = firestore.Client()
doc_ref = db.collection(u'collection_name').document(u'document_name')
doc_ref.set({u'test_col': Increment(1)}, merge=True)
@A-Iskakov Thanks - It worked!
Most helpful comment
@binojohnthomas as a temp solution you can use this way:
from google.cloud.firestore_v1 import Incrementdb = firestore.Client()doc_ref = db.collection(u'collection_name').document(u'document_name')doc_ref.set({u'test_col': Increment(1)}, merge=True)