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

179
Vistas
react firebase add new document to collection

I want to remove every value-field from the document "view-count" in the "server-details" collection in react with firebase. Currently I am deleting the document with deleteDoc() but I can't figure out how to create the document again. Here is my code:

    const resetViewCounter = async () => {

        const valueDoc = doc(database, "server-details", "view-count");
        await deleteDoc(valueDoc);
        await addDoc(valueDoc);

        // window.location.reload(false); // temporarily
    }

Thanks for your help!

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I think you're looking for setDoc(valueDoc.ref, {}).

But I'd recommend actually deleting the specific fields, with FieldValue.delete as shown in the documentation on deleting fields.

about 4 years ago · Santiago Trujillo 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