swift - 将元素添加到 Firestore 数组时获取“类型‘FieldValue’没有成员‘arrayUnion’”
问题描述
当我在 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'
这个问题的任何解决方案?
解决方案
这可能是因为您有一个“旧”版本的 iOS SDK。arrayUnion 功能已在 2018 年 8 月 2 日的版本 5.5.0 中实施。
有关更多详细信息,请参阅https://firebase.google.com/support/release-notes/ios。
推荐阅读
- r - 读取批量 CSV 和过滤以摆脱标题不起作用
- r - 在 geom_sf (R ggplot) 中为颜色条图例添加逗号
- php - 无法添加值 xml
- android - 将结束与元素开始相对布局对齐
- quaternions - 使用向上向量查看四元数
- python - 在列表中找到一段字符串并替换
- angular5 - 如何触发类似于 $(' ').trigger('click') 在 div by 角度 5 中的函数单击的事件?
- javascript - 找出调用了哪些 AngularJS 函数
- django - Django:一个没有模型的多个数据库
- python - numpy.all 和二进制序列的按位“&”之间的比较