是否可以重命名Firestore集合中的字段? [英] Is it possible to rename fields in firestore collection?
问题描述
我是Firebase中Cloud Firestore的新手.在我的项目中,我已经创建了集合,但是我需要为每个集合重命名字段名称.是否有可能?任何帮助将不胜感激.
I am new to Cloud Firestore in Firebase. In my project I have created collections but I need to rename field names for each collection. Is it possible? Any help will be highly appreciated.
推荐答案
是否可以重命名Firestore集合中的字段?
Is it possible to rename fields in firestore collection?
不,不是,没有API可以这样做.在Firestore中,一旦创建属性,便无法更改它们的名称.所有这些字段都是不可变的.
No, it's not, there is no API for doing that. In Firestore it's not possible to change the names of your properties once you have created them. All that fields are immutable.
一种解决方法是读取您的文档,进行必要的更改,然后使用新的属性名称将其全部重新放置.
A workaround would be to read your documents, make the necessary changes and then put it all back in with the new property names.
这篇关于是否可以重命名Firestore集合中的字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!