且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何更新 firebase firestore 中的文档 ID?

更新时间:2022-12-30 13:10:42

我认为没有办法更改文档 ID,但即使有办法,您所做的也是非常错误的.ID 应该是唯一标识符,让自己成为一个 UserID 字段,例如使用 Firebase Auth 使用 firebase.Auth().currentUser.uid 作为 Firestore 中用户特定保存数据的 ID.

I dont think there is a way to Change the Document ID, but even if there is a way what you do is horribly wrong. The ID should be a Unique Identifier, make yourself a UserID Field, for example with Firebase Auth use firebase.Auth().currentUser.uid as the ID of your User specific saved data in the Firestore.

我建议您总体上进行更改,以解决您的问题,更重要的是为您提供稳固的结构.(来自 Auth 的 UID 是唯一的)

I Suggest you to Change that in General that solves your Problem and more importantly gives you a solid structure. (The UID from the Auth is Unique)