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

383
Views
Firebase React: Remove Item (Map) from array in firestore

I'm trying to remove a map item from an array in firebase. From what I understand with firebase - you are unable to delete the item based on the index. Should I structure this a different way or is there an easier way to remove a specific object from the array? Thank you

Error: 'No document to update: '

enter image description here

  const listingRef = doc(db, 'users', 'savedListings');

  const deleteListing = async () => {
    try {
      await updateDoc(listingRef, {
        savedListings: deleteField()
      });
    } catch (e) {
      console.log(e.message);
    }
  };```
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

The doc() takes path to a document that should be users/test@user.com in this case. While you can use arrayRemove() to remove elements from an array field you cannot delete an object from an array unless you know the exact value that object including all the fields.

const listingRef = doc(db, 'users', 'USER_EMAIL'); // USER_EMAIL is document ID

const deleteListing = async () => {
  try {
    await updateDoc(listingRef, {
      savedListings: arrayRemove("THAT_OBJECT")
    });
  } catch (e) {
    console.log(e.message);
  }
};

If you don't have that exact object, then you'll have to read the document, manually remove the element from array and update the document back.

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