2

I want to create/update a set of data in the cloud firestore in that is stored in a nested array method.

enter image description here I want to define the nested array to be in a Map<String, dynamic> method like this.

Rahul Variya
  • 1,257
  • 1
  • 6
  • 15
  • Please follow below questions: https://stackoverflow.com/questions/67838039/flutter-firestore-update-array-of-object-by-param – Rahul Variya Feb 03 '23 at 06:35

1 Answers1

2

First, you have to create instance of categories model then change the value according to your requirement

for ex:

 Categories c =  categories; // here assign your exiting data of categories
     c.copyWith(flavor : ["hello","world"]);

          await FirebaseFirestore.instance
          .collection('user')
          .doc(FirebaseAuth.instance.currentUser?.uid)
          .collection('todos')
          .doc(map["collectionId"])
          .update(FieldValue.arrayUnion(c)))
Rahul Variya
  • 1,257
  • 1
  • 6
  • 15