我正在编写Flutter应用,并试图将元素添加到数组中。我正在尝试遵循以下示例:https : //firebase.google.com/docs/firestore/manage-data/add-data#update_elements_in_an_array-但是,“我的DocumentReference”对象没有更新对象:
那么,如何在本文档中向数组添加元素?
供参考,我使用cloud_firestore:0.12.1依赖项。
您应该使用的方法是updateData()。您将其传递给它。
这是将元素(字符串“ element”)添加到数组(宽松命名为“ arrayName”)的示例:
userPantry.updateData({'arrayName': FieldValue.arrayUnion(['element'])})
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句