Flutter: How to update an Array within an Array in the firestore

放肆的年华 提交于 2021-02-17 06:54:32

问题


banco firestore

I need to update a status field in the index array [0] where time == 8:00, I need to pass this status to == "0", only that this array is inside a matrix that here in the image can be seen as a timer. How could I update this vector at index [0] by changing the status = 1 field to = 0?

To update a status outside an array and passing the values by hand I am using an example like this for testing only:

Firestore.instance.collection("area").document("alergia").collection("items")
     .document("RGiqOihmSxUlpVVEqPUo").collection("agenda").document("bgMHxqQEpt8Tha0pdOcY")
        .updateData({"statusdata": 0});

回答1:


Firestore doesn't offer any updates that allow you to directly change array items by their index. You will have to write code to read the document, modify the array in memory to be the way you want, then update the array field back to the document.



来源:https://stackoverflow.com/questions/61212886/flutter-how-to-update-an-array-within-an-array-in-the-firestore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!