I would like to automatically increment by one in Firebase. If the user sends a message, the data inside Firebase will be incremented by one.
I would appreciate any help.
CodePudding user response:
Use FieldValue.increment()
FirebaseFirestore.instance
.collection('users')
.doc('ABC123')
.update({'count': FieldValue.increment( 1)})
or use transaction
or use cloud trigger