Fra*_*cia 2 android firebase google-cloud-firestore
我已经在测试新的FirestoreAPI了,我在文档和update调用方面遇到了一些问题.
我正在尝试更新一个没有现有的文件,我收到了一个错误.显然这很好,因为文档说update如果DocumentReference不存在,调用将失败.但是,阅读官方文档,我看到下一段代码:
// Update the population, creating the document if it
// does not already exist.
db.collection("cities").document("Beijing").update(
new UpdateOptions().createIfMissing(),
"population",
21500000);
Run Code Online (Sandbox Code Playgroud)
我试图复制这个,但我找不到UpdateOptions电话.另外,检查这些的不同覆盖方法update不是这种调用的构造函数.
我正在使用11.4.2Firebase版本.知道发生了什么事吗?
Firestore API在测试版发布之前就已更改,并且UpdateOptions不再存在.如果您想将字段合并到可能存在或可能不存在的文档中,请执行以下操作set:
Map<String, Object> data = new HashMap<>();
data.put("population", 21500000);
db.collection("cities").document("Beijing")
.set(data, SetOptions.merge());
Run Code Online (Sandbox Code Playgroud)
遗憾的是,我们的翻译文档目前已过期,请暂时参考英文版.
| 归档时间: |
|
| 查看次数: |
853 次 |
| 最近记录: |