[Delete-user-data] Question: How to delete one to many relations?
I would like to use the "delete-user-data" extension, but I have a problem: We use firebase for an ecommerce app and the users can make purchases. These purchases are saved in cloud-firestore as:
purchases --> Random UID: - UserID: UserUID - OrderDate: Date - Amount: XYZ - ETC
My question is: How can I configure my "cloud-firestore-paths" in the user-delete-extension in order to delete any purchase which the customer made, e.g. any purchases-document which contains the particular user-uid?
Based on the following thread, it's not possible
- https://github.com/firebase/extensions/issues/305
You have to write your own firebase function. You can be inspired by this extension
- https://github.com/firebase/extensions/blob/master/delete-user-data/functions/src/index.ts
Or in the thread above there is a gist of advanced delete-user-data feature
- https://gist.github.com/TylerAHolden/10d0ee986a8a1f743fa09154118b177b
@Berki2021 thanks for the request. Since there was also another thread (#305) asking for the same feature we're going to take a deeper look into it.
@Berki2021 are you willing to help us understand what your needs are? If so can you reach out to my email ([email protected]) ?
Hi, in our use case we also need a similar implementation. We have a model or object which is many to many with different users, so if a user wish to delete the account, we should delete all the user data, so we should search a collection base on the userId who is deleting the account and delete all the records that belongs to the user.
Not sure if I'm explaining correctly but I think is a common usecase, another one is that there is a collection where a user can create as many records as they want, but is a parent collection, so there is a field for the owner of the record.
I think for now we will make our own implementation, but I really believe this can be a common use case specially with apple now making mandatory the account deletion within the app, so probably a lot more people wants to use this extension
https://developer.apple.com/news/?id=mdkbobfo
Hi all,
I'm just going through some long running issues across the extensions repo.
I think the current version of the extension has an "Auto Discovery" feature, which should support your scenario:
Since your purchase documents contain a UserID field that matches the user's UID, you can enable auto discovery and specify the field to search for. You should configure the extension as follows:
- Set Enable auto discovery to true
- Set Auto discovery search fields to UserID
- Set Auto discovery search depth to an appropriate level (default 3 should work for your case)
Hopefully this resolves the issue.
I'm going to close this as complete for now, but if this does not resolve the issue or i've misunderstood, feel free to reply or reopen the issue!