Home > OS >  How to automatically increment by one in Firebase?
How to automatically increment by one in Firebase?

Time:02-25

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.

CodePudding user response:

Use FieldValue.increment()

FirebaseFirestore.instance
  .collection('users')
  .doc('ABC123')
  .update({'count': FieldValue.increment( 1)})

or use transaction

or use cloud trigger

  • Related