Flutter:如何在Firestore中更新阵列中的阵列 [英] Flutter: How to update an Array within an Array in the firestore

查看:39
本文介绍了Flutter:如何在Firestore中更新阵列中的阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

banco firestore

我需要更新索引数组[0]中的状态字段,其中时间== 8:00,我需要将此状态传递给=="0",只不过此数组位于矩阵中,图像可以看作是计时器.如何通过将状态= 1字段更改为= 0来更新索引[0]处的向量?

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});

推荐答案

Firestore不提供任何允许您直接通过数组索引更改数组项的更新.您将必须编写代码来阅读文档,以所需的方式修改内存中的数组,然后将数组字段更新回文档.

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.

这篇关于Flutter:如何在Firestore中更新阵列中的阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆