diff --git a/source/includes/write/gridfs.php b/source/includes/write/gridfs.php index 104a90cf..bb94ce63 100644 --- a/source/includes/write/gridfs.php +++ b/source/includes/write/gridfs.php @@ -81,21 +81,11 @@ function toJSON(object $document): string // end-download-to-stream // Renames a file from the GridFS bucket with the specified ObjectId -// start-rename-files-id +// start-rename-files $bucket->rename(new ObjectId('66e0a5487c880f844c0a32b1'), 'new_file_name'); -// end-rename-files-id - -// Renames files from the GridFS bucket with the specified filename -// start-rename-files-name -$bucket->renameByName('my_file', 'new_file_name'); -// end-rename-files-name +// end-rename-files // Deletes a file from the GridFS bucket with the specified ObjectId -// start-delete-files-id +// start-delete-files $bucket->delete(new ObjectId('66e0a5487c880f844c0a32b1')); -// end-delete-files-id - -// Deletes a file and its revisions from the GridFS bucket by name -// start-delete-files-name -$bucket->deleteByName('my_file'); -// end-delete-files-name +// end-delete-files diff --git a/source/read/distinct.txt b/source/read/distinct.txt index 8a71ca01..31d88bd5 100644 --- a/source/read/distinct.txt +++ b/source/read/distinct.txt @@ -138,10 +138,6 @@ options you can set to customize the operation: - | The read preference to use for the operation. To learn more, see :manual:`Read Preference ` in the Server manual. | **Type**: ``MongoDB\Driver\ReadPreference`` - - * - ``hint`` - - | The index to use for the operation. - | **Type**: ``string|object`` The following example retrieves the distinct values of the ``name`` field for all documents that have a ``borough`` field value of ``'Bronx'`` and a diff --git a/source/write/gridfs.txt b/source/write/gridfs.txt index 0ceb287e..3415dc8f 100644 --- a/source/write/gridfs.txt +++ b/source/write/gridfs.txt @@ -375,65 +375,48 @@ Rename Files ------------ Use the ``MongoDB\GridFS\Bucket::rename()`` method to update the name of -a GridFS file in your bucket. Pass the following parameters to the ``rename()`` -method: - -- ``_id`` value of the file you want to rename -- New file name +a GridFS file in your bucket. You must specify the file to rename by its +``_id`` field rather than its file name. The following example shows how to update the ``filename`` field to -``'new_file_name'`` by referencing a file's ``_id`` value: +``'new_file_name'`` by referencing a document's ``_id`` field: .. literalinclude:: /includes/write/gridfs.php :language: php :dedent: - :start-after: start-rename-files-id - :end-before: end-rename-files-id - -Alternatively, you can use the ``MongoDB\GridFS\Bucket::renameByName()`` -method to rename a GridFS file and all its file revisions. Pass the -following parameters to the ``renameByName()`` method: + :start-after: start-rename-files + :end-before: end-rename-files -- ``filename`` value you want to change -- New file name +.. note:: File Revisions -The following example renames all files that have a ``filename`` value -of ``'my_file'``: - -.. literalinclude:: /includes/write/gridfs.php - :language: php - :dedent: - :start-after: start-rename-files-name - :end-before: end-rename-files-name + The ``rename()`` method supports updating the name of only one file at + a time. If you want to rename each file revision, or files with different upload + times that share the same file name, collect the ``_id`` values of each revision. + Then, pass each value in separate calls to the ``rename()`` method. .. _gridfs-delete-files: Delete Files ------------ -Use the ``MongoDB\GridFS\Bucket::delete()`` method to remove a GridFS file's collection +Use the ``MongoDB\GridFS\Bucket::delete()`` method to remove a file's collection document and associated chunks from your bucket. This effectively deletes the file. -Pass the ``_id`` value of the file you want to delete as a parameter to the -``delete()`` method. +You must specify the file by its ``_id`` field rather than its file name. The following example shows you how to delete a file by referencing its ``_id`` field: .. literalinclude:: /includes/write/gridfs.php :language: php :dedent: - :start-after: start-delete-files-id - :end-before: end-delete-files-id + :start-after: start-delete-files + :end-before: end-delete-files -Alternatively, you can use the ``MongoDB\GridFS\Bucket::deleteByName()`` method -to delete a GridFS file and all its file revisions. Pass the ``filename`` value of the -file you want to delete as a parameter to the ``deleteByName()`` method, as shown -in the following code: +.. note:: File Revisions -.. literalinclude:: /includes/write/gridfs.php - :language: php - :dedent: - :start-after: start-delete-files-name - :end-before: end-delete-files-name + The ``delete()`` method supports deleting only one file at a time. If + you want to delete each file revision, or files with different upload + times that share the same file name, collect the ``_id`` values of each revision. + Then, pass each value in separate calls to the ``delete()`` method. API Documentation -----------------