Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] delete-user-data: Delete subcollections #14

Closed
claust opened this issue Sep 27, 2019 · 13 comments
Closed

[FR] delete-user-data: Delete subcollections #14

claust opened this issue Sep 27, 2019 · 13 comments
Assignees
Labels
type: feature request New feature or request

Comments

@claust
Copy link

claust commented Sep 27, 2019

[REQUIRED] Step 2: Extension name

This feature request is for extension: delete-user-data

What feature would you like to see?

It would be helpful if the delete-user-data extension could delete all documents in subcollections as well.

How would you use it?

Often you would have one or more subcollections below a user profile document.
Example: /users/{UID}/stories or /users/{UID}/likes.

In this case it would be really nice if the extension could delete all documents in a specified subcollection, or maybe all documents in any subcollections (recursively). This is not trivial to implement, and therefore fits very nicely in the delete-user-data extension.

@Ehesp
Copy link
Member

Ehesp commented Sep 27, 2019

Let's open discussion on this one. By default a delete won't delete subcollections, as its not always desired.

We could either do this by default, mention in the docs how to do this (provide explicit additional paths), or implement some wildcard paths.

@thatfiredev
Copy link
Member

I vote to make it a default. I mean, if we're deleting all of the user data, it wouldn't make sense to keep subcollections under that UID.

@horaciocome1
Copy link

Yes! It is easy to think it should be default, but it would be cool if there had an optional parameter where one specifies if he fits or not in this common case.

Lets say one has an later function that is trigged when user data is deleted. The main goal of the function is to archive someplace stories and likes. Perhaps he wants to notify followers.
What you guys think of this?

@chenlevy
Copy link
Contributor

I think it would be better to allow users to determine if they want to delete a subcollection.

Using an explicit path:
/users/{UID}/notifications

And in case the UID is saved in a document field:
/notifications(userId=UID)

@claust
Copy link
Author

claust commented Sep 30, 2019

Having the ability to keep (documents in) subcollections is kind of an advanced feature, and I believe it makes good sense to recursively delete all (documents in) subcollections by default. This is probably by far the most likely need and expectation of the developers, rather than the other.

It should also be a design goal of Firebase Extensions to be really simple to use. So minimizing the need of configuration for most users would be nice.

So if you have the special need to keep one or more of any subcollections, I think it would make sense to write your own function.

@Ehesp
Copy link
Member

Ehesp commented Sep 30, 2019

cc @karayu - let me know your thoughts on the above. Another idea is to have a dropdown/select option on setup, which gives developers the option (defaults to non-recursive).

@andreivladmatei
Copy link

I believe the most common use-case is to delete user/{UID} and user/{UID}/subcollections by default.

When I first installed the extension, that was the way I thought it will go and found out that it's not.

@karayu
Copy link
Contributor

karayu commented Oct 1, 2019

Thanks so much for the feedback! I think this is a great feature request and would make this extension much more helpful. @Ehesp Let's sync directly on how we can make this happen!

@Salakar Salakar added the type: feature request New feature or request label Oct 1, 2019
@Ehesp Ehesp self-assigned this Oct 2, 2019
@Ehesp
Copy link
Member

Ehesp commented Oct 3, 2019

Currently working on this feature, however I've hit an issue. To carry out a recursive delete with the firebase-tools repository, a user token is required. As the extension runs in isolation, the admin SDK would have to generate this token using a valid UID... However, as the extension is triggered when a user is deleted, the token generated from the UID is invalid causing the recursive delete to fail.

@samtstern
Copy link
Contributor

samtstern commented Oct 3, 2019 via email

@Ehesp
Copy link
Member

Ehesp commented Oct 4, 2019

#25

I was having IAM issues when uninstalling the extension (issued raised internally) which caused the token issue. All sorted now in the above PR.

@jimmykane
Copy link

Its true. I thought this extension would do a recursive sub-collection delete which is the main pain of deleting user data.

@laurenzlong
Copy link
Contributor

Fixed in v0.1.2: https://github.com/firebase/extensions/releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request New feature or request
Projects
None yet
Development

No branches or pull requests