如何在 Cloud Firestore 的批量写操作中添加 Firebase 用户配置文件更新?

huangapple go评论89阅读模式
英文:

How can I add a FirebaseUser profile update to a batched write with Cloud Firestore?

问题

我正在尝试使用 Cloud Firestore 进行批量写操作。当执行批量写操作时,它将使用用户选择的新个人资料图片链接更新数据库中用户的文档。我还希望使用 UserProfileChangeRequest.Builder() 将此更新直接应用于 FirebaseUser。是否有一种方式可以将 FirebaseUser 的更新添加到批量写操作中,以便这两个更新可以同时进行?

英文:

I am trying to perform a batched write with Cloud Firestore. When the batched write is performed, it will update the user's document in the database with the link to the new profile image that the user has selected. I also want to perform this update directly to the FirebaseUser using UserProfileChangeRequest.Builder(). Is there some way I can add the FirebaseUser update to the batched write so that the two updates happen simultaneously?

答案1

得分: 1

不,将多个产品之间的多个操作转变为单个原子操作是不可能的。您将需要分别执行并检查每个操作的结果,如果出现问题,则撤消任何先前的更改。我建议首先进行可逆选项(数据库写入)。或者可以简单地忽略Firebase Auth的配置信息,因为在您拥有数据库的情况下,这些信息实际上并不是必需的。

英文:

No, it's not possible to turn multiple operations among multiple products into a single atomic operation. You will have to perform and check the result of each on independently, and undo any prior changes if there are problems. I suggest doing the reversible option (database write) first. Or simply ignore the Firebase Auth profile information, since it's not really necessary for anything while you have the database available.

huangapple
  • 本文由 发表于 2020年9月16日 08:37:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/63911558.html
  • android
  • firebase-authentication
  • google-cloud-firestore
  • java
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定