-
Notifications
You must be signed in to change notification settings - Fork 244
DRIVERS-2807 Update GridFS spec to add delete_by_name
and rename_by_name
#1702
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -649,6 +649,32 @@ orphaned chunks with files_id equal to id before raising the error. | |
|
||
If a networking or server error occurs, drivers MUST raise an error. | ||
|
||
### File deletion by filename | ||
|
||
To rename all revisions of a stored file with the specified filename, drivers SHOULD provide the method | ||
`delete_by_name`: | ||
|
||
```javascript | ||
class GridFSBucket { | ||
|
||
/** | ||
* Deletes all stored files with the specified @filename from a GridFS bucket. | ||
*/ | ||
void delete_by_name(string filename); | ||
|
||
} | ||
``` | ||
|
||
This method is an optimisation over deleting each revision of a stored file individually. | ||
|
||
**Implementation details:** | ||
|
||
Drivers MUST first find the `_id` field of all files collection documents with the given filename. Drivers MUST then | ||
delete all files collection documents with the found ids. Drivers MUST then delete all chunks with `files_id` in the | ||
found ids that were just deleted. | ||
|
||
If there are no files collection documents with the given filename, drivers MUST raise an error. | ||
|
||
### Generic Find on Files Collection | ||
|
||
```javascript | ||
|
@@ -821,11 +847,34 @@ Sets the filename field in the stored file's files collection document to the ne | |
Drivers construct and execute an update_one command on the files collection using `{ _id: @id }` as the filter and | ||
`{ $set : { filename : "new_filename" } }` as the update parameter. | ||
|
||
To rename multiple revisions of the same filename, users must retrieve the full list of files collection documents for a | ||
given filename and execute "rename" on each corresponding `_id`. | ||
If `renameByName` is not implemented to rename multiple revisions of the same filename, users must retrieve the full | ||
list of files collection documents for a given filename and execute "rename" on each corresponding `_id`. | ||
|
||
If there is no file with the given id, drivers MUST raise an error. | ||
|
||
### Renaming stored files by filename | ||
|
||
To rename all revisions of a stored file with the specified filename, drivers SHOULD provide the method | ||
`rename_by_name`: | ||
Comment on lines
+857
to
+858
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One thing I did not think about is if there is already a newer file with the new filename, then it will stay the last revision for this filename. We can't change the date of the renamed files, as that would change the order of the revisions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct that seems like expected behavior to me. |
||
|
||
```javascript | ||
class GridFSBucket { | ||
|
||
/** | ||
* Renames all revisions of the stored file with the specified @filename. | ||
*/ | ||
void rename_by_name(string filename, string new_filename); | ||
|
||
} | ||
``` | ||
|
||
**Implementation details:** | ||
|
||
Drivers construct and execute an update_many command on the files collection using `{ filename: @filename }` as the | ||
filter and `{ $set : { filename : "new_filename" } }` as the update parameter. | ||
|
||
If there is no file with the given filename, drivers MUST raise an error. | ||
|
||
### Dropping an entire GridFS bucket | ||
|
||
```javascript | ||
|
@@ -1042,6 +1091,7 @@ system?") it is a potential area of growth for the future. | |
|
||
## Changelog | ||
|
||
- 2024-10-30: Add `delete_by_name` and `rename_by_name` | ||
- 2024-10-28: Removed deprecated fields from tests: `md5`, `contentType`, `aliases` | ||
- 2024-02-27: Migrated from reStructuredText to Markdown. | ||
- 2016-05-10: Support custom file ids | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.