【发布时间】:2021-10-30 05:08:17
【问题描述】:
我有一个 Firebase 函数,它可以更新不同集合中的许多相关内容。我想使用批量写入,以便没有部分更新,全部或全部。但我的问题是,这些更新中的每一个都发生在不同的功能中,例如:
await update1(data) // update to firestore
await update2(data) // update to firestore and realtime
await update3(data) // update to firestore and auth
我想我可以将对 batchWrite 的引用传递给每个函数?然后在所有更新结束时运行 batch.commit()。我认为这可行,但出现的问题是其中一些更新函数会更新 auth() 和实时数据库中的内容。我怎样才能用 Firestore 写入全部或全部写入?我曾想过返回一个回调函数来执行身份验证和实时更新,这将在成功的 batch.commit 上调用,但如果这些失败了怎么办......
如何使用不同的数据库(Firestore、Auth、Realtime)构建多功能批量写入?
谢谢
【问题讨论】:
标签: javascript firebase firebase-realtime-database google-cloud-firestore firebase-authentication