0
const choiceUpdate = async (dynamicValue) =>{
    const increment = firebase.firestore.FieldValue.increment(1);
    const storyRef = db.collection('group').doc(roomCode);
    const response = await storyRef.update({[`businesses.${dynamicValue}.swipe`]: increment});
};

Photo of firestore db

Photo of firestore db

I'm not sure how to increment swipe, the dynamicValue is the index of the [businesses] array. It's a counter for keeping track of how many people liked the restaurant.

Dharmaraj
  • 29,469
  • 5
  • 26
  • 55
  • You cannot update an object at given index directly in Firestore atm. You'll have to read the document, modify the array and update whole new array back in the document. Checkout linked answers for more details. – Dharmaraj Apr 19 '22 at 17:42

0 Answers0