-
Notifications
You must be signed in to change notification settings - Fork 147
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
Add a dry run option to recursiveDelete #1751
Comments
I am using this alternative for now (async () => {
const users = [
'7BHpq4x5epX7fXSJpd3XJbjb0b03',
'AX4xmwEACNcHy9FMmX9MFmaTQXJ3',
'CmQ2gPIxMLORjf8raKEszJ0lbNq2',
'ccwj6u2CQzbuq4OQmSPvoVXxCSO2',
];
const bulkWriter = firestore.bulkWriter();
bulkWriter.delete = async (ref) => {
console.log(ref.path);
return { writeTime: Timestamp.fromDate(new Date()), isEqual: () => false };
};
for (const uid of users) {
const doc = firestore.collection('users').doc(uid);
await firestore.recursiveDelete(doc, bulkWriter);
}
process.exit(0);
})(); |
Hi @sushantdhiman, thanks for your feature request. Can you tell us more about your use case for listing all documents that will be deleted in a recursive delete? What kind of user is performing the recursive delete? And in what context are they performing the delete? Is the path the only information that is relevant to the user that is about to perform the recursiveDelete? Thanks, |
Hi, Please find the answers for your questions below :-
Given dangerous consequence of performing
Developer (with GCP Project Admin access). For my context, I was just pruning database of some disabled accounts with a maintenance script.
In my case number of parent / target documents were small, so yeah listing them was enough to be sure that not all the users will be deleted. For any case, I just want to be sure that I am not going to delete something unexpected by mistake. Perhaps tree like structure (with depth control) can be used for this. In some cases just showing count of documents to be deleted should enough. Even just displaying the full path of parent document could be enough. An example output could be like this :- .
├── 7BHpq4x5epX7fXSJpd3XJbjb0b03/
│ └── purchases/
│ ├── pX7fXS
│ └── wEACN
├── AX4xmwEACNcHy9FMmX9MFmaTQXJ3/
│ └── purchases/
│ └── PvoVXx
├── CmQ2gPIxMLORjf8raKEszJ0lbNq2/
│ └── invites/
│ └── jf8raKEszJ0lbNq2
└── ccwj6u2CQzbuq4OQmSPvoVXxCSO2
Total document: 8 |
I appreciate the additional details on this feature request. I've put this request in our backlog for scheduling in a future sprint. In the meantime, please follow up with any additional questions or concerns. (b/241146361) |
Is your feature request related to a problem? Please describe.
recursiveDelete
is a dangerously destructive operation. I think there should be a way to list document(s) that will be deleted.Describe the solution you'd like
Add a third argument to
recursiveDelete
method,options?.dryRun: boolean
The text was updated successfully, but these errors were encountered: