简体   繁体   English

Firebase Cloud Firestore:在集合中为每个 UID 创建一个新文档

[英]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.

相关问题 未创建文档的 Cloud Firestore 子集合 - Cloud Firestore Sub-Collection on a Document not Creating flutter firestore 未在云 firestore 数据库中创建文档 - flutter firestore not creating a document in the cloud firestore database Cloud FireStore 多个文档具有相同的 iD,即用户 UID - Cloud FireStore multiple document with same iD which is the user UID 如何将 user.uid 作为 id 的文档添加到 Firebase 中的集合中? - How to add a document with user.uid as id to a collection in Firebase? 如何在 Cloud firestore 中动态创建新集合? - How to create new collection in Cloud firestore dynamically? 如何检索作为文档放置在 Firebase Cloud Firestore 中的 UID - How do I retrieve the UID's that I have placed as documents in my Firebase Cloud Firestore Firestore - 获取路径未知的 ID 文档 - Firebase Cloud Functions - Firestore - Get document with ID whose path is unknown - Firebase Cloud Functions Firestore接管一分钟搞定里面的文档 Firebase Cloud Function - Firestore take over a minute to get a document inside Firebase Cloud Function 使用 angular 在 Firebase Cloud Functions (Firestore) 中获取单个文档 ID - Getting single document ID in Firebase Cloud Functions (Firestore) with angular 用户在 Cloud firestore 中注册时如何将当前用户 uid 添加到用户集合? - how to add current user uid to user collection when user signup in cloud firestore?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM