是否可以仅使用一个请求在Firestore中存储多个文档?使用此循环可能但这会导致列表中的每个项目进行一次保存操作.
for (counter in counters) {
val counterDocRef = FirebaseFirestore.getInstance()
.document("users/${auth.currentUser!!.uid}/lists/${listId}/counters/${counter.id}")
val counterData = mapOf(
"name" to counter.name,
"score" to counter.score,
)
counterDocRef.set(counterData)
}
Run Code Online (Sandbox Code Playgroud) 我有一组带有生成标识符的文档.问题是:是否可以在不查询所有文档数据的情况下获取标识符列表?将这些密钥存储在单独的集合中更好吗?
我正在使用Cloud Firestore并拥有一组文档.对于集合中的每个文档,我想更新其中一个字段.
使用事务执行更新效率很低,因为在更新数据时我不需要读取任何数据.
批量更新似乎是正确的方向,但是文档不包括一次更新多个文档的示例.请参见此处:批量写入
java firebase firebase-realtime-database google-cloud-firestore