如何在实时db(flutter)中更新(类型表< string>)的地图值?

发布于 2025-02-12 14:56:45 字数 254 浏览 0 评论 0 原文

我正在尝试为表选择添加新值(这是一个元素map< string,动态>)。我该怎么做? “ alt =”在此处输入图像描述”>

I'm trying to add a new value to the table choices (which is an element in a map<string,dynamic>). How can I do it ?enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往昔成烟 2025-02-19 14:56:45

如果不读取整个数组,则无法在Firebase实时数据库中的数组中添加元素。因此,您必须:

  1. 读取数组中的当前元素,
  2. 项目添加到阵列

将 使用列表或地图。我建议您查看最佳实践:firebase 。

There is no way to add an element to an array in the Firebase Realtime Database without first reading the entire array. So you'll have to:

  1. Read the current elements in the array
  2. Add the item to the array
  3. Write the entire array back to the database

This is one of the (many) reasons why Firebase recommends against using arrays for list-like structures and prefers using lists or maps. I recommend checking out Best Practices: Arrays in Firebase.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文