Answers for "firebase is there a way to rename a document"

0

firebase is there a way to rename a document

const firestore = firebase.firestore();
// get the data from '[email protected]'
firestore.collection("users").doc("[email protected]").get().then(function (doc) {
    if (doc && doc.exists) {
        var data = doc.data();
        // saves the data to 'name'
        firestore.collection("users").doc("name").set(data).then({
            // deletes the old document
            firestore.collection("users").doc("[email protected]").delete();
        });
    }
});
Posted by: Guest on August-29-2021

Code answers related to "firebase is there a way to rename a document"

Code answers related to "Javascript"

Browse Popular Code Answers by Language