Flutter: Update specific index in list (Firestore)

后端 未结 1 1652
臣服心动
臣服心动 2020-12-11 14:37

How exactly do you update a specific value in a list based on it\'s index? For example, in the following list:

0 [
    {
      first_name: name0,
      last_         


        
相关标签:
1条回答
  • 2020-12-11 14:55

    For all client languages and platforms, it's currently not possibly to issue a single command to update an array item by index. There is no special syntax for that. What you will need to do instead is read the document, modify the field array data in the way that you want, and update that field back to the document, in its entirety. You can do this in a transaction if you want the update to be atomic.

    See also:

    • Is there any way to update a specific index from the array in Firestore
    • Firestore Update single item in an array field
    • How to update an array item in Firestore
    • How to update an "array of objects" with Firestore?
    0 讨论(0)
提交回复
热议问题