本文介绍了Firebase Cloud功能-为用户创建更多信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在寻找在云功能中创建具有其他信息的用户的最佳方法.明显的可能性似乎是创建一个创建用户文档的触发器:

I am currently looking for the best way to create a user with additional information in a cloud function. The obvious possibility seems to create a trigger which creates a user document:

functions.auth.user().onCreate((user) => { /* Create user document in firestore with base information*/ });

然后将信息添加到创建的文档中.(兑现诺言)

And afterwards add the information to the created document. (Handle the promise)

但是我对这种解决方案并不满意.我宁愿一次性完成所有这些工作.有人有更好的解决方案吗?

But one way or another I don't feel really satisfied with this solution. I would rather do all this stuff in one go. Does someone have a better solution?

推荐答案

如果要将其他用户数据保存在firebase中,建议在注册新添加的用户之后在前端处理此数据.

If you want to save additional user data in firebase I would recommend to handle this in your front-end after the newly added user is registered.

完成注册承诺后,在您的前端中,获取用户ID并使用要保存的初始数据来执行数据库设置(例如,在 users/$ {userid} 中).

In your front-end once the registration promise is fulfilled, get the userid and perform a database set for example in users/${userid} with the initial data you want to save.

这篇关于Firebase Cloud功能-为用户创建更多信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 15:21