Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

421
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!