Assuming you have a structure that looks like this:
Firestore-root
|
--- departments (collection)
|
--- $departmentId (document)
|
--- users (collection)
|
--- $uid (document)
|
--- //user data
To be able to achieve this:
I want to delete all the documents in "departments" without documents in the users
sub-collection.
You have to get all documents in the users
sub-collection and delete them. But remember, such an operation is not really recommended by the Firebase team to be done on the client, if you have a large number of documents inside your collection. However, for a small number of documents, it will work.
The most important thing in this operation is that if you delete those documents, the sub-collections will continue to exist, and deleted documents will be displayed in italic.
Only in the Realtime Database, if you delete a node, you delete it with all the data that exists beneath it. But here is not the case, so no worries.