firebase increment value code example

Example 1: Firestore increment field

const userRef = db.collection('documents').doc('document_id');
const increment = firebase.firestore.FieldValue.increment(1);

userRef.update({ FieldToIncrease: increment });

Example 2: Firestore decrement field

const userRef = db.collection('documents').doc('document_id');
const decrement = firebase.firestore.FieldValue.increment(-1);

userRef.update({ fieldToDecrease: decrement });

Example 3: firebase realtime database increment value

Just do that manually
// get val from database
// increment val
// set val in database