1

I'm trying to do this:

database.collection('UsuariosDev').where('Telefono', '==', textInput.current.value)
    .update({
        citas: firebase.firestore.FieldValue.arrayUnion(database.doc('NegociosDev/Peluquerías/Negocios/PR01/citas/' + docRef.id))
})

Get the doc from the collection "UsuariosDev" where "Telefono" equals "textInput.current.value", and then update it. But it seems like I can't use "update" next to "where". Any ideas?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
David Díaz
  • 89
  • 4
  • 15

1 Answers1

1

Firestore doesn't support update queries. To update a document you need to know its full path. So to update all documents matching a query, you'll need to:

  1. Execute that query against the database
  2. Loop over the resulting documents
  3. Update each document in turn

Also see:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807