简体   繁体   中英

How can i change document id in firebase

How can I change document ID in firebase? I have human readable document IDs which contains characters that are problematic, eg non latin or "-" which disappear after I deslugify them, how can i change them. I try to do it directly in the console but I don't seem to be able to, can i do it programatically?

Thanks

No, once a document has been created, you cannot modify document ID's. See this question .

What you can do instead is read in the old document, create a new one with the ID you want and the data from the original, and then delete the original. You will want to do these actions within a transaction to make sure that they are completed in their entirety.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM