如何在Firebase中的列表字段中添加值? [英] How to add a value to list field in firebase?

查看:43
本文介绍了如何在Firebase中的列表字段中添加值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 firebase 数据库中有一个 array 类型的字段,我想对其进行添加.

I have a field of type array in my firebase database and I want to add to it new values.

我想要什么代码:

Firestore.instance.collection('lists').document(123).setData({
  'myList': FieldValue.add(**myValue**);
});

推荐答案

这应该有效:

Firestore.instance.collection('lists').document(123).updateData({
  'myList': FieldValue.arrayUnion(['el1', 'el2'])
});

这篇关于如何在Firebase中的列表字段中添加值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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