• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: deleting a collection that includes a nested sub collection in firebase?

Resolved: deleting a collection that includes a nested sub collection in firebase?

0
By Isaac Tonny on 18/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I have the following batch, where I delete three documents in a collection, the data-set-c collection however has one nested collection for massages where each message is a doc each.
the problem is that the (data-set-c) collection never gets deleted, I don’t know if it is due to the nesting taking place? will deleting this way affect also sub-collection? or is it the rules that are blocking it since my rules are specific to the deepest level endpoint, or should use the cloud function instead since this doc will be massive later on, and each day is massages collection but the main issue here is how to delete this one level nested structure.
could you please take a look and see what I am doing wrong.


enter image description here

Answer:

the problem is that the (data-set-c) collection never gets deleted.


That’s the expected behavior. If you delete a document, doesn’t mean that you delete all sub-collections that exist within that document. Besides that, that document ID will continue to exist and the Firebase Console will display it in italic.

will deleting this way affect also sub-collection?


No, it won’t.

or is it the rules that are blocking it since my rules are specific to the deepest level endpoint.


If it was about the security rules, then you would have received an error indicating that.

or should use cloud function instead since this doc will be massive later on


Yes, you can indeed use a Cloud Function to delete all documents that exist in all sub-collection of the document that was deleted.

How to delete this one-level nested structure.


You can achieve this by iterating each sub-collection, and by deleting each document. But don’t do it on the client!

If you have better answer, please add a comment about this, thank you!

firebase-security google-cloud-platform javascript
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Using AWK to count multiple patterns in a file

01/04/2023

Resolved: significance letter above bar graphic in wrong order

01/04/2023

Resolved: VBA – Applying border around the areas with value/text

01/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.