var jobskill_ref = db.collection('job_skills').where('job_id','==',post.job_id); jobskill_ref.delete(); Error lanzado
jobkill_ref.delete no es una función
Solo puede eliminar un documento una vez que tenga una DocumentReference . Para obtener eso, primero debe ejecutar la consulta, luego recorrer QuerySnapshot y finalmente eliminar cada DocumentSnapshot en función de su 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(); }); });Utilizo escrituras por lotes para esto. Por ejemplo:
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 asíncrono/espera:
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();//The following code will find and delete the document from firestore const doc = await this.noteRef.where('userId', '==', userId).get(); doc.forEach(element => { element.ref.delete(); console.log(`deleted: ${element.id}`); });