如何编辑Firestore中存在的数组元素 [英] how to edit an array element present in firestore

查看:60
本文介绍了如何编辑Firestore中存在的数组元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在firestore中有一个字符串数组.我想编辑出现在特定索引处的字符串.我怎样才能做到这一点?

I have an array of strings present in firestore. I want to edit the string present at a particular index. How can I do this?

例如,让数组为["help","me","please"];

For example, let the array be ["help","me","please"];

如何在扑朔迷离中将帮助"更改为不帮助"?

How can I change "help" to "don't help" in flutter?

我最接近编辑数组的地方是添加一个元素,这由FieldValue.arrayunion()完​​成.

The closest I've gotten to editing the array is adding an element, which I do by FieldValue.arrayunion().

是否可以编辑存在于特定索引处的元素?还是我必须获取整个阵列,在本地对其进行更新,然后上传整个阵列?

Is it possible to edit an element present at a particular index? Or am I gonna have to fetch the entire array, update it locally, and then upload the entire array?

推荐答案

单个更新是不可能的.您必须完全按照说的做:阅读文档,对内存中的数组进行更改,然后将新的数组写回到文档中.

It's not possible with a single update. You have to do exactly as you said: read the document, make changes to the array in memory, write the new array back to the document.

这篇关于如何编辑Firestore中存在的数组元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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