How to delete subcolletion of document in firebase?
This is my code where I am getting subcollection "tieredRewards" and company id's which has tiered rewards. I want to delete tieredReward subcollection in every company.
let _query1 = query(collection(db, "companies"));
const companiesSnapshot = await getDocs(_query3);
companiesSnapshot.docs.map(async (doc) => {
let _query2 = query(
collection(db, `companies/${doc.id}/tieredRewards`)
);
const tieredRewardsSnapShot = await getDocs(_query4);
if (!tieredRewardsSnapShot.empty) {
console.log(doc.id);
}
});
I tried deleteDoc
method, but it did not work.