Is there a way to update the name of a Firebase / Firestore document?

0

Assuming my collection is something like the following:

/eventos/
  180812-fiesta { ... }
  180813-reunion { ... }
  180814-concierto { ... }

If you would like, for example, change the name of the document 180812-fiesta . Is there any way to do it?

This is how the documents are created:

this.db.collection('eventos').doc(id).set(data);

At the moment, it only occurs to me to delete the document and create a new one with the new name and the same data, but I would like to know if there is a better way to solve this.

    
asked by akko 14.08.2018 в 19:57
source

1 answer

2

Currently there is no way to modify the id of a node (Firebase RTDB) or of a Document (Firestore), these are immutable once the element is created.

The best alternative that occurs to me is to recover the doc / node you want to rename, assign it to a new UID and then delete the old / doc node.

    
answered by 14.08.2018 / 22:41
source