showing results for - "firebase is there a way to rename a document"
Rylan
07 Jan 2017
1const firestore = firebase.firestore();
2// get the data from 'name@xxx.com'
3firestore.collection("users").doc("name@xxx.com").get().then(function (doc) {
4    if (doc && doc.exists) {
5        var data = doc.data();
6        // saves the data to 'name'
7        firestore.collection("users").doc("name").set(data).then({
8            // deletes the old document
9            firestore.collection("users").doc("name@xxx.com").delete();
10        });
11    }
12});
13