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

134
Views
React Native Firestore document deletion

I'm trying to run the code below, but it doesn't work. Can you help me?

await followRequestsColl.doc()
        .where('Followed', '==', user.uid)
        .where('Following', '==', targetUserUid)
        .delete().then(() => {
          console.log('User deleted!');
        });

Error : Possible Unhandled Promise Rejection (id: 6): TypeError: followRequestsColl.doc().where is not a function. (In 'followRequestsColl.doc().where('Followed', '==', user.uid)', 'followRequestsColl.doc().where' is undefined)

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You should only search in collections:

await followRequestsColl.collection('somecollectionname')
    .where('Followed', '==', user.uid)
    .where('Following', '==', targetUserUid)
    .delete().then(() => {
      console.log('User deleted!');
    });
about 4 years ago · Juan Pablo Isaza Report

0

In addition to RobrechtVMs observation that you can't query a document. you also can't call delete() on a query.

You will have to:

  1. Execute the query
  2. Loop over the results
  3. Delete each document in turn

Something like:

const query = followRequestsColl.collection('somecollectionname')
  .where('Followed', '==', user.uid)
  .where('Following', '==', targetUserUid);
query.get().then((snapshot) => {
  snapshot.docs.forEach((doc) => {
    doc.ref.delete();
  })
})

Also see: How to delete document from firestore using where clause

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!