Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

166
Visualizações
How to delete a document inside a subcollection

I have a collection STUDENTS which has a sub collection PLAYLIST what I want to do is deleting the documents inside the PLAYLIST

this is the code I have tried

    const result = await deleteDoc(doc(db, path, dataId));

the path is "Students/student_id/Playlist" the dataID is the document i wanted to delete but there are no result when i trigger this action

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

To delete all the documents inside a sub-collection, you should loop the snapshot and call the deleteDoc() method. See code below:

const querySnapshot = await getDocs(collection(db, "students", "<student_id>", "playlist"));

querySnapshot.forEach((doc) => {
  deleteDoc(doc.ref);
});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda