英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论