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

395
Vistas
Setting up a counter in a document and then retrieve it using Firestore: Would this be alright or would this be too expensive?

Under the orders collection, I created a document called counts which would store the counts for the status of the orders:

enter image description here

I then created a function to increment the status with "delivered"

And then to display this:

 useEffect(async () => {
    const docRef = doc(db, "orders", "counts");
    const docSnap = await getDoc(docRef);

    if (docSnap.exists()) {
      console.log("Document data:", docSnap.data());
    } else {
      // doc.data() will be undefined in this case
      console.log("No such document!");
    }
  }, []);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Yes, this is one way to do it I suppose, 'expensive', that's up to you and how many calls you might end up with, as I know Firestore has a limited amount of free document calls.

Another thing is you should not, and I repeat should not make a useEffect asynchronous, the best and right way to perform asynchronous code inside a useEffect would be to declare it inside and then run it like below

useEffect(() => { 
    const AsyncExample = async () => { 
      // async code in here 
    }
    AsyncExample() 
}, [])
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