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中得到想法,很抱歉误解了你的问题。我更新了我的答案。