How to add map inside document in firestore using flutter?

Ali Coder

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:

enter image description here 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.

Doug Stevenson

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]

編集
0

コメントを追加

0

関連記事

分類Dev

How to create a collection inside a uid document in Firestore using Flutter?

分類Dev

How to listen for document changes in Cloud Firestore using Flutter?

分類Dev

How to query using unique document id in Firestore from flutter?

分類Dev

Flutter Firebase - How to Add User uid to Document

分類Dev

How to add/remove from a firestore map field?

分類Dev

Dart/Flutter How to initialize a List inside a Map?

分類Dev

how to set custom object with document id to a collection in firestore in flutter?

分類Dev

Flutter: how to add an "if" logic inside of a build function in flutter

分類Dev

Convert Firestore DocumentSnapshot to Map in Flutter

分類Dev

Flutter and Firestore! Set a Collection, a document and a field

分類Dev

Deleting document from cloud_firestore in flutter

分類Dev

Firestore/Flutter: querying document's subcollection

分類Dev

How to get sub-collections of every collection in Firestore using Flutter

分類Dev

Flutter and Firestore: How can access variables from Stateful Widget to create a new document?

分類Dev

Flutter Firestore: How to avoid conflicts in writing/updating a document that is available to multiple users at the same time?

分類Dev

Firestore add Field to Document with POST request and HttpsURLConnection

分類Dev

Flutter firestore fetch documents with a condition on a map field

分類Dev

How to add a json in a nested array of a mongodb document using Spring?

分類Dev

How to add an image into a spot colour channel for a PDF document using ABCpdf?

分類Dev

How to add multiple map objects (JSON's) to cloud-firestore database?

分類Dev

Flutter video_player with URL from Firestore Document

分類Dev

How to add a condition inside or after .Select() using Linq EF

分類Dev

Cloud Firestore: how to reference another document?

分類Dev

Firestore update with merge - how to overwrite a part of the document

分類Dev

How to prevent unnecessary Document read in Firestore?

分類Dev

How to update the propriety of a field objects in a firestore document?

分類Dev

Adding an Object to Cloud Firestore using Flutter

分類Dev

rails add image inside the map method

分類Dev

Flutter Cloud Firestore Map <String、dynamic>エラー

Related 関連記事

  1. 1

    How to create a collection inside a uid document in Firestore using Flutter?

  2. 2

    How to listen for document changes in Cloud Firestore using Flutter?

  3. 3

    How to query using unique document id in Firestore from flutter?

  4. 4

    Flutter Firebase - How to Add User uid to Document

  5. 5

    How to add/remove from a firestore map field?

  6. 6

    Dart/Flutter How to initialize a List inside a Map?

  7. 7

    how to set custom object with document id to a collection in firestore in flutter?

  8. 8

    Flutter: how to add an "if" logic inside of a build function in flutter

  9. 9

    Convert Firestore DocumentSnapshot to Map in Flutter

  10. 10

    Flutter and Firestore! Set a Collection, a document and a field

  11. 11

    Deleting document from cloud_firestore in flutter

  12. 12

    Firestore/Flutter: querying document's subcollection

  13. 13

    How to get sub-collections of every collection in Firestore using Flutter

  14. 14

    Flutter and Firestore: How can access variables from Stateful Widget to create a new document?

  15. 15

    Flutter Firestore: How to avoid conflicts in writing/updating a document that is available to multiple users at the same time?

  16. 16

    Firestore add Field to Document with POST request and HttpsURLConnection

  17. 17

    Flutter firestore fetch documents with a condition on a map field

  18. 18

    How to add a json in a nested array of a mongodb document using Spring?

  19. 19

    How to add an image into a spot colour channel for a PDF document using ABCpdf?

  20. 20

    How to add multiple map objects (JSON's) to cloud-firestore database?

  21. 21

    Flutter video_player with URL from Firestore Document

  22. 22

    How to add a condition inside or after .Select() using Linq EF

  23. 23

    Cloud Firestore: how to reference another document?

  24. 24

    Firestore update with merge - how to overwrite a part of the document

  25. 25

    How to prevent unnecessary Document read in Firestore?

  26. 26

    How to update the propriety of a field objects in a firestore document?

  27. 27

    Adding an Object to Cloud Firestore using Flutter

  28. 28

    rails add image inside the map method

  29. 29

    Flutter Cloud Firestore Map <String、dynamic>エラー

ホットタグ

アーカイブ