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

  • 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. – Frank van Puffelen Oct 04 '22 at 00:05
  • so how do i read the likes number and update it? –  Oct 04 '22 at 00: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. – Frank van Puffelen Oct 04 '22 at 00:49

0 Answers0