可以创建 'transaction' 以通过 firebase 身份验证添加新用户并写入 firestore 吗?

Possible to create 'transaction' for adding new user via firebase auth and writing to firestore?

我的新用户流程中有一个步骤,用户在 Firebase 身份验证中注册,然后将记录写入 Firestore。

有没有一种简单的方法可以将用户注册和 firebase 写入都放入一个事务中,这样如果其中一个失败,它们都会失败?

Is there a straightforward way to put both the user registration and the firebase write into a transaction, so if either one fails, they both fail?

没有Firebase products that support cross-product transactional operations. You'll have to nest both calls and always handle the errors. So do the authentication, and then write the data to Firestore or the Realtime Database.

处理这种情况的更方便的方法是trigger a Cloud Functions in response to the creation of a Firebase user account。这样,您只需要在客户端处理一个操作。