0

I have a firestore document that has a lot of nested objects and lists and I need to update a particular value in an ArrayList: enter image description here

I need to update that checked value. I thought I would be able to update it easily by doing:

db.collection("users").document(user.getUid()).update(
    "weeks[" + (weekNum - 1) + "].checked", currentCheckBox.isChecked());

However, I am realizing you can't do that with an ArrayList in Firestore. I understand I could do an ArrayUnion but that would mean recreating that entire index in the array and it would end up getting added at the end of the ArrayList. Is there any possible way to update this checked value?

Slaknation
  • 2,124
  • 3
  • 23
  • 42
  • 1
    There is currently no single database operation for updating an array item like this. You have to read the document, modify the array item in memory, then update the entire array field back to the document. – Doug Stevenson Dec 20 '18 at 20:53
  • Thanks. That is disappointing. – Slaknation Dec 20 '18 at 20:58

0 Answers0