I am using map inside array in firestore document. The problem is that when i am adding maps with new values then instead of increasing the size of array it is replacing new map with current map. My code is look like this:
Map<String, dynamic> map = {'name': "Asad"};
RaisedButton(
child: Text("press me"),
onPressed: () {
Firestore.instance.collection('Shops').document('2').setData({
'name': 'Ali',
'id': '3',
'array': FieldValue.arrayUnion([map])
});
},
),
And my firestore db looks like this:
How to increase the size of array or you can say how to add new element inside array instead of replacing it.Thanks in advance.
If you want to update a document instead of overwriting its content, you should use updateData() instead of setData(). Either that, or pass {merge: true}
to setData() as the second argument.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加