firestore update() function cast updated data to map

后端 未结 1 946
日久生厌
日久生厌 2021-01-28 23:13

I\'m trying to update some data in my firestore database and the data inside is Map> in other words, a map of lists. so when I\'m tr

1条回答
  •  孤独总比滥情好
    2021-01-28 23:51

    There is no way to update an item in an array field by its index. Instead you'll have to:

    1. read the entire array into your application code
    2. update the array in memory
    3. write the entire updated array back to the database

    The exception to this is when your array contains unique, unordered values, such as when you for example store an array of the tags for a post. In that case you can use the arrayUnion operator to manipulate the array. However your case looks different, so you'll have to use the above steps.

    This questions comes up quite regularly, so I recommend reading some of these:

    • I need to update a certain array entry of my Map in Firestore
    • How to update elements in arrays of maps in Firestore?
    • How to update array elements in Firestore with Android?
    • How to update arrayList in cloud firestore in android

    0 讨论(0)
提交回复
热议问题