mongodb / mongodb/specifications

`delete_many` function for GridFS

Open
#1,882 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
409
Forks
248
Avg merge
3d 9h
Merged PRs (30d)
7

Description

Coming here from https://github.com/mongodb/mongo-rust-driver/issues/1589

Use-case

We get a load of uploads by users which are only needed for finishing a process and afterward for documentation and debugging purposes, at least for a few months. After that time we need to clean up the files in our GridFS database, that can amount to a few ten-thousand files.

Current state

As far as I have seen, right now there is no way to directly do this on GridFS, except to find every file id and then delete every file via an .delete(id) execution, which, in our case, would result in a few ten-thousand database requests.
The other way would be to use regular database queries. First find all matching documents in the fs.files collection, then find all related documents in the fs.chunks collection and now delete everything, with at least two additional database delete_many queries. But only, if everything works out. Otherwise, you would need to check which files, or chunks, weren't deleted and try to delete them again, by which ever means/strategy/algorithm.

Proposal

Provide a delete_many function that takes a filter as parameter. This function should delete all matching fs.files documents and their related entries in fs.chunks, similar to a regular delete_many

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked mongo-rust-driver issue and the GridFS behavior described here, focusing on how filters select fs.files documents and how related fs.chunks entries are handled. Define the delete_many API and its deletion semantics, including what completion should guarantee for matching files and chunks.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.