【问题标题】:Getting "Type 'FieldValue' has no member 'arrayUnion'" when adding element to Firestore array将元素添加到 Firestore 数组时获取“类型‘FieldValue’没有成员‘arrayUnion’”
【发布时间】:2018-09-29 11:05:07
【问题描述】:

当我在 Xcode 中使用这段代码时:

let washingtonRef = db.collection("cities").document("DC")

// Atomically add a new region to the "regions" array field.
washingtonRef.updateData([
    "regions": FieldValue.arrayUnion(["greater_virginia"])
])

// Atomically remove a region from the "regions" array field.
washingtonRef.updateData([
    "regions": FieldValue.arrayRemove(["east_coast"])
])

这是Firebase Website 中的一个示例,我收到以下错误:

Type 'FieldValue' has no member 'arrayUnion'

这个问题有什么解决办法吗?

【问题讨论】:

    标签: swift firebase google-cloud-firestore


    【解决方案1】:

    这可能是因为您有一个“旧”版本的 iOS SDK。 arrayUnion 功能已在 2018 年 8 月 2 日的版本 5.5.0 中实现。

    更多详情请参阅https://firebase.google.com/support/release-notes/ios

    【讨论】:

    • 已解决。谢谢!
    猜你喜欢
    • 2023-01-23
    • 2019-02-19
    • 1970-01-01
    • 1970-01-01
    • 2019-04-14
    • 2020-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多