0

i'm trying to update a document without knowing the specific ID of this document.

My document on firebase:

My document on firebase

I searched on the internet and find this (update cloud firestore document without id) ;

const db = Firebase.firestore()
    db.collection('users').where("email", "==", currentUser.email).get(function(querySnapshot){
        querySnapshot.forEach(function(document){
            document.ref.update({
                "firstname" : "world",
                "name" : "testing"
            })
        });
    })

it doesn't show me an error and doesn't change anything in firestore.

const handleSubmit = (e) => {
    e.preventDefault()
    const db = Firebase.firestore()
    db.collection('users').where("email", "==", currentUser.email).get().then(querySnapshot => {
        querySnapshot.forEach(doc =>  
            "firstname" : "world",
            "name" : "testing"
        }))
    })
}

and this show me an error ; doc.update is not a function and I don't really understand why. If anyone can enlighten me!

Thanks!

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
ZeDOver
  • 25
  • 4

0 Answers0