firedart
firedart copied to clipboard
arrayUnion support for arrays
Flutter firestore has something like this to add items to arrays
Firestore.instance
.collection('YourCollection')
.document('YourDocument')
.updateData({'array':FieldValue.arrayUnion(['data1','data2','data3'])});
Is this possible with this library yet?
The nodejs library also has the following (https://googleapis.dev/nodejs/firestore/latest/FieldValue.html)

Here is how flutterfire implements it:
https://github.com/FirebaseExtended/flutterfire/blob/44e07cc2a0a8700a86290b383b03bc974c5d633a/packages/cloud_firestore/cloud_firestore/lib/src/field_value.dart
Those methods then call _CodecUtility. It looks like its using "FieldValueFactoryPlatform" which are platform specific so this may not be possible with rest api.
I don't think this is currently possible (I'd have to test to be sure though).
It seems like some sort of advanced features that I don't expect most people to need. I wouldn't be against someone submitting a pull request for it but honestly if you need to do a lot of work with individual items in a list, you'd probably be better off just implementing it as a collection rather than an array inside a document.
Hi I am facing the same problem is there anyone that could help me ????
Firestore.instance .collection('YourCollection') .document('YourDocument') .updateData({'array':FieldValue.arrayUnion(['data1','data2','data3'])});
How to do this with firedart?????
The arrayUnion operator in the Firebase SDKs maps to appendMissingElements. in the Firestore REST API. See https://firebase.google.com/docs/firestore/reference/rest/v1beta1/Write for more into.