0

I'm trying to update the likes on a post from the app when a button is pressed. The posts are located in an array and I'm trying to update the int of the likes of the post.

Below is the firestore enter image description here

This is the button code. It isn't working. enter image description here

3
  • There is no way to update an item in an array by an index. You'll have to read the document, get the current value for the posts array, update that, and write the entire (updated) array back to the database. Commented Oct 4, 2022 at 0:05
  • so how do i read the likes number and update it? Commented Oct 4, 2022 at 0:11
  • Exactly as I said: read the document, get the array from it, update the value, and write the entire array back to the document. Commented Oct 4, 2022 at 0:49

0