如何向 firebase 中的列表字段添加值?

the*_*der 1 dart firebase flutter google-cloud-firestore

我的firebase数据库中有一个数组类型字段,我想向其中添加新

我想要什么代码:

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

Igo*_*din 6

这应该有效:

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