Skip to content

Commit 85ff041

Browse files
authored
Revert v1.21 changes (#190)
* Revert "DOCSP-45100: Delete and rename by name (#187)" This reverts commit 6c72463. * Revert "Merge pull request #181 from mcmorisi/DRIVERS-2658-hint" This reverts commit 02755ef.
1 parent 6c72463 commit 85ff041

File tree

3 files changed

+23
-54
lines changed

3 files changed

+23
-54
lines changed

source/includes/write/gridfs.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,11 @@ function toJSON(object $document): string
8181
// end-download-to-stream
8282

8383
// Renames a file from the GridFS bucket with the specified ObjectId
84-
// start-rename-files-id
84+
// start-rename-files
8585
$bucket->rename(new ObjectId('66e0a5487c880f844c0a32b1'), 'new_file_name');
86-
// end-rename-files-id
87-
88-
// Renames files from the GridFS bucket with the specified filename
89-
// start-rename-files-name
90-
$bucket->renameByName('my_file', 'new_file_name');
91-
// end-rename-files-name
86+
// end-rename-files
9287

9388
// Deletes a file from the GridFS bucket with the specified ObjectId
94-
// start-delete-files-id
89+
// start-delete-files
9590
$bucket->delete(new ObjectId('66e0a5487c880f844c0a32b1'));
96-
// end-delete-files-id
97-
98-
// Deletes a file and its revisions from the GridFS bucket by name
99-
// start-delete-files-name
100-
$bucket->deleteByName('my_file');
101-
// end-delete-files-name
91+
// end-delete-files

source/read/distinct.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@ options you can set to customize the operation:
138138
- | The read preference to use for the operation. To learn more, see
139139
:manual:`Read Preference </core/read-preference/>` in the Server manual.
140140
| **Type**: ``MongoDB\Driver\ReadPreference``
141-
142-
* - ``hint``
143-
- | The index to use for the operation.
144-
| **Type**: ``string|object``
145141

146142
The following example retrieves the distinct values of the ``name`` field for
147143
all documents that have a ``borough`` field value of ``'Bronx'`` and a

source/write/gridfs.txt

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -375,65 +375,48 @@ Rename Files
375375
------------
376376

377377
Use the ``MongoDB\GridFS\Bucket::rename()`` method to update the name of
378-
a GridFS file in your bucket. Pass the following parameters to the ``rename()``
379-
method:
380-
381-
- ``_id`` value of the file you want to rename
382-
- New file name
378+
a GridFS file in your bucket. You must specify the file to rename by its
379+
``_id`` field rather than its file name.
383380

384381
The following example shows how to update the ``filename`` field to
385-
``'new_file_name'`` by referencing a file's ``_id`` value:
382+
``'new_file_name'`` by referencing a document's ``_id`` field:
386383

387384
.. literalinclude:: /includes/write/gridfs.php
388385
:language: php
389386
:dedent:
390-
:start-after: start-rename-files-id
391-
:end-before: end-rename-files-id
392-
393-
Alternatively, you can use the ``MongoDB\GridFS\Bucket::renameByName()``
394-
method to rename a GridFS file and all its file revisions. Pass the
395-
following parameters to the ``renameByName()`` method:
387+
:start-after: start-rename-files
388+
:end-before: end-rename-files
396389

397-
- ``filename`` value you want to change
398-
- New file name
390+
.. note:: File Revisions
399391

400-
The following example renames all files that have a ``filename`` value
401-
of ``'my_file'``:
402-
403-
.. literalinclude:: /includes/write/gridfs.php
404-
:language: php
405-
:dedent:
406-
:start-after: start-rename-files-name
407-
:end-before: end-rename-files-name
392+
The ``rename()`` method supports updating the name of only one file at
393+
a time. If you want to rename each file revision, or files with different upload
394+
times that share the same file name, collect the ``_id`` values of each revision.
395+
Then, pass each value in separate calls to the ``rename()`` method.
408396

409397
.. _gridfs-delete-files:
410398

411399
Delete Files
412400
------------
413401

414-
Use the ``MongoDB\GridFS\Bucket::delete()`` method to remove a GridFS file's collection
402+
Use the ``MongoDB\GridFS\Bucket::delete()`` method to remove a file's collection
415403
document and associated chunks from your bucket. This effectively deletes the file.
416-
Pass the ``_id`` value of the file you want to delete as a parameter to the
417-
``delete()`` method.
404+
You must specify the file by its ``_id`` field rather than its file name.
418405

419406
The following example shows you how to delete a file by referencing its ``_id`` field:
420407

421408
.. literalinclude:: /includes/write/gridfs.php
422409
:language: php
423410
:dedent:
424-
:start-after: start-delete-files-id
425-
:end-before: end-delete-files-id
411+
:start-after: start-delete-files
412+
:end-before: end-delete-files
426413

427-
Alternatively, you can use the ``MongoDB\GridFS\Bucket::deleteByName()`` method
428-
to delete a GridFS file and all its file revisions. Pass the ``filename`` value of the
429-
file you want to delete as a parameter to the ``deleteByName()`` method, as shown
430-
in the following code:
414+
.. note:: File Revisions
431415

432-
.. literalinclude:: /includes/write/gridfs.php
433-
:language: php
434-
:dedent:
435-
:start-after: start-delete-files-name
436-
:end-before: end-delete-files-name
416+
The ``delete()`` method supports deleting only one file at a time. If
417+
you want to delete each file revision, or files with different upload
418+
times that share the same file name, collect the ``_id`` values of each revision.
419+
Then, pass each value in separate calls to the ``delete()`` method.
437420

438421
API Documentation
439422
-----------------

0 commit comments

Comments
 (0)