Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase 是否可以更新firestore上的指定数组?_Firebase_Flutter_Dart_Google Cloud Firestore - Fatal编程技术网

Firebase 是否可以更新firestore上的指定数组?

Firebase 是否可以更新firestore上的指定数组?,firebase,flutter,dart,google-cloud-firestore,Firebase,Flutter,Dart,Google Cloud Firestore,我有这样一个数组: firestore.instance. .collection('friendships') .document(caller.data["uid"]) .updateData({ "groups.groupId": { FieldValue.arrayUnion({ friendDisplayName: snapshot.data["friendDisplayName"],

我有这样一个数组:

firestore.instance.
    .collection('friendships')
    .document(caller.data["uid"])
    .updateData({
         "groups.groupId": {
              FieldValue.arrayUnion({
              friendDisplayName: snapshot.data["friendDisplayName"],
              friendUid: snapshot.ref
         })
});


我需要向组添加另一个id。\u name=group 2(向设备添加一个新id)。

目前,firestore中不可能这样做。我建议将外部数组设置为一个对象,然后可以执行如下操作:

firestore.instance.
    .collection('friendships')
    .document(caller.data["uid"])
    .updateData({
         "groups.groupId": {
              FieldValue.arrayUnion({
              friendDisplayName: snapshot.data["friendDisplayName"],
              friendUid: snapshot.ref
         })
});

我需要添加组名称等于组2。你可以从图片(我附上)@BloodLoss中得到想法,很抱歉误解了你的问题。我更新了我的答案。