0

so i want to update inside the array

here is the database look like

enter image description here

               static Future<void> EditObat(
               String? namarsgm,
               int nominal,
               idobat,
               ) async 
               {
                  await Database.doc(hospital).update(
                  {
                   'Obat'[idobat]: FieldValue.arrayUnion({'Banyak' : 
                     FieldValue.increment(nominal)}),
                  },
                  );
               }

So i want to increase the value 'Banyak', and after research, i still haven't make it anyone know how to solve this ?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Silent Roar
  • 29
  • 1
  • 4
  • There is no way to update an item in an array in Firestore. You will have to read the document, update the array in your application code, and then write the entire array back to the database. – Frank van Puffelen Apr 19 '23 at 13:32

0 Answers0