Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

502
Vistas
How to update a Firestore field to give it an empty value (undefined or null)?

My Firestore document has a field with a value already set.

Now I want to remove the value by setting it to something that signifies "empty" such as null or undefined.

So far I have tried doing this with the updateDoc method like so:

updateDoc(documentReference,{ photoURL: undefined })

But it throws this error:

Function updateDoc() called with invalid data. Unsupported field value: undefined (found in field photoURL in document users/d23xxxxxxxxxxxxxxx12)

And setting it to null is also not allowed because if I try to set it to null like so:

updateDoc(documentReference,{ photoURL: null })

TypeScript will throw this error:

Type 'null' is not assignable to type 'FieldValue | Partial | undefined'.

I found that using an empty string like updateDoc(documentReference,{ photoURL: "" }) works but it's not as elegant as null or undefined.

I will use the empty string if no other solutions are found, but perhaps there is another way?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Firestore does not recognize javascript undefined as a valid value. You can see the valid types in the documentation. Null is a valid type, so you should be able to use that. If you are not, then you should file a bug against the SDK that you're using. If you're using the web client SDK, use this GitHub. Be sure to provide complete steps to reproduce.

If you want to simply remove the field altogether so that it has no type at all, just remove the field and check for the the missing field in the code the performs the query.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda