[英]Firebase Cloud Firestore: Creating a new document in a collection for every UID
I want to implement a badge system into my Firebase project, but I already have a lot of users.我想在我的 Firebase 项目中实现徽章系统,但我已经有很多用户了。 I want to take all the UIDs of my existing users, and create a new corresponding document for them in my new collection,
userinfo
.我想获取现有用户的所有 UID,并在我的新集合
userinfo
中为他们创建一个新的对应文档。
I've searched the docs and I cannot find a way to do this.我已经搜索了文档,但找不到执行此操作的方法。 Can I get some help creating the documents?
我可以得到一些创建文件的帮助吗?
If you want to create a new document for each user that already exists in the (users) collection to another (userinfo) collection, then you have to read all documents from the "users" collection and perform a write operation in the "userinfo" collection.如果要为 (users) 集合中已存在的每个用户创建一个新文档到另一个 (userinfo) 集合,那么您必须从“users”集合中读取所有文档并在“userinfo”中执行写操作收藏。 But bear in mind to not perform such an operation on the client, but in a trusted environment, such as a server that you control, or using Cloud Functions for Firebase .
但切记不要在客户端执行这样的操作,而是在受信任的环境中,例如您控制的服务器,或者使用Firebase 的 Cloud Functions 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.