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

432
Vistas
Uncaught (in promise) FirebaseError: No document to update

I made a firestore database that looks like this.

enter image description here

I'm trying to make "stocks : 999" value change, so that it can be 998, 997, etc...

So I followed given instructions on firebase documentation (https://firebase.google.com/docs/firestore/manage-data/add-data#web-version-9_8), but I bump into an error when trying to make it work.

const [stock, SetStock] = useState([]);
const toUpdate = doc(db, "stocks", "stocks");

  useEffect(
    () =>
      onSnapshot(collection(db, "stocks"),(snapshot) => 
      SetStock(snapshot.docs[0].data().stocks)
     ),
 [] 
 );
 
 const update = () => {
   updateDoc(toUpdate, {
    stocks : increment(-1)
  });
  
 }

In here, the important things are const toUpdate = doc(db, "stocks", "stocks") and const update = ()..., the other are working great.

Anyways, after clicking the button that triggers "update", I get an error that says enter image description here

Why ?

By the way, I am using React, I don't know if this might be useful.

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

0

Your code is trying to update a document with the path "/stocks/stocks". The error message is telling you that document doesn't exist. I'm inclined to agree, since the document you show in the screenshow has the path "/stocks/sL..G1" (redacted). You will need to use the correct document ID to build a path to the document to update.

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