且构网

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

如何在Firebase Firestore中更新文档ID?

更新时间:2022-12-30 12:48:04

我不认为有一种更改文档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.

我建议您总体上进行更改,以解决您的问题,更重要的是为您提供坚实的结构. (身份验证中的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)