Answers for "Firestore increment field"

4

Firestore increment field

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

userRef.update({ FieldToIncrease: increment });
Posted by: Guest on July-03-2020
2

Firestore decrement field

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

userRef.update({ fieldToDecrease: decrement });
Posted by: Guest on July-03-2020

Code answers related to "Firestore increment field"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language