ios - 为什么 FieldValue.increment() 在 Swift 中给我一个错误?
问题描述
所以我唯一改变的是添加:
pod 'Geofirestore'
使用 Firestore 到我的 IOS 应用程序的 podfile,其中包含以下内容:
pod 'Firebase/Core'
pod 'Firebase/Firestore'
pod 'Firebase/Auth'
pod 'Firebase/Storage'
pod 'GooglePlaces'
pod 'GoogleMaps'
pod 'Geofirestore'
pod 'InstantSearch', '~> 5.0'
突然间,我在 Firestore 中更新字段值的代码行抛出了错误。这些行:
db.collection("people").document(userID!).updateData(["listsCount": FieldValue.increment(Int64(1))])
现在给我错误:
类型“FieldValue”没有成员“增量”
对于我的生活,我无法弄清楚突然发生了什么变化。任何帮助表示赞赏。
解决方案
我能够通过Double
在更新字段之前将我的值初始化为 a 来解决此问题。这样,Firebase 知道如何解释增量,可以是Double
或Int64
let value: Double = 1
ref.updateData([
"likeCount" : FieldValue.increment(value)
])
推荐阅读
- python - 在阈值python中查找像素值
- ruby-on-rails - Ruby:使用 class_eval 定义常量只能通过 const_get 找到,但不能直接通过 :: 查找
- htmlunit - HtmlUnit 在页面加载时抛出错误“java.util.NoSuchElementException”
- javascript - 我想在完整日历上显示每月事件
- html - Jquery formdata post with express js
- javascript - 从异步处理 REST 的 Promise 循环中轮询部分数据
- javascript - 我想我在 javascript 中发现了一个错误
- node.js - 根据用户位置动态更改页面内容
- c - vmstat -m /slabtop 对象数量和内存泄漏
- python - 将编辑后的 CSV 输入写入 JSON 文件