how to increment a value in firebase field 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 });