gpt4 book ai didi

dart - 如何在 Flutter cloud_firestore 中更新数组值?

转载 作者:IT王子 更新时间:2023-10-29 07:05:58 26 4
gpt4 key购买 nike

我有一个包含数组字段的文档。

如何更新数组?

在 firebase 函数中,使用 typescript ,我做了这样的事情:

admin.firestore()
.collection('friendships')
.doc(caller.data["uid"])
.update({
friends: admin.firestore.FieldValue
.arrayUnion({
friendDisplayName: snapshot.data["friendDisplayName"],
friendUid: snapshot.ref
})
})

我找不到 Flutter 的任何替代方案。我该怎么办?

最佳答案

像这样

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

关于dart - 如何在 Flutter cloud_firestore 中更新数组值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52728270/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com