var jobskill_ref = db.collection('job_skills').where('job_id','==',post.job_id); jobskill_ref.delete();   Error thrown
jobskill_ref.delete is not a function
Call the doc() method and pass references of database, collection name and ID of a document that we want to delete. Assign it to a constant called docRef. Let's make a deleteDoc() query to perform deleting a document from a cities collection in Cloud Firestore.
Which of the following method is used to delete a field from a particular document in firebase? Deleting Fields For deleting a specific field from a document, use the FieldValue. delete() method when we update a document.
You can only delete a document once you have a DocumentReference to it. To get that you must first execute the query, then loop over the QuerySnapshot and finally delete each DocumentSnapshot based on its ref.
var jobskill_query = db.collection('job_skills').where('job_id','==',post.job_id); jobskill_query.get().then(function(querySnapshot) {   querySnapshot.forEach(function(doc) {     doc.ref.delete();   }); }); 
                        I use batched writes for this. For example:
var jobskill_ref = db.collection('job_skills').where('job_id','==',post.job_id); let batch = firestore.batch();  jobskill_ref   .get()   .then(snapshot => {     snapshot.docs.forEach(doc => {       batch.delete(doc.ref);     });     return batch.commit();   })   ES6 async/await:
const jobskills = await store   .collection('job_skills')   .where('job_id', '==', post.job_id)   .get();  const batch = store.batch();  jobskills.forEach(doc => {   batch.delete(doc.ref); });  await batch.commit(); 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With