是否可以仅使用一个请求在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)