Skip to content

Commit 5ac7b4c

Browse files
committed
NR PR fixes 1
1 parent 6cb7cc6 commit 5ac7b4c

File tree

4 files changed

+30
-39
lines changed

4 files changed

+30
-39
lines changed

docs/fundamentals/write-operations.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ methods that you can use to write data to MongoDB by using
3232

3333
.. tip::
3434

35-
To learn more about any of the methods shown on this page, see the
36-
links provided in each section.
35+
To learn more about any of the methods included in this guide,
36+
see the links provided in each section.
3737

3838
Insert One
3939
----------
@@ -160,7 +160,7 @@ collection:
160160
To view a runnable example that deletes one document, see the
161161
:ref:`laravel-delete-one-usage` usage example.
162162

163-
To learn more about inserting documents, see the
163+
To learn more about deleting documents, see the
164164
:ref:`laravel-fundamentals-write-delete` guide.
165165

166166
Delete Multiple
@@ -177,5 +177,5 @@ collection:
177177
To view a runnable example that deletes multiple documents, see the
178178
:ref:`laravel-delete-many-usage` usage example.
179179

180-
To learn more about inserting documents, see the
180+
To learn more about deleting documents, see the
181181
:ref:`laravel-fundamentals-write-delete` guide.

docs/fundamentals/write-operations/delete.txt

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ You can delete one document in the following ways:
4242
- Call the ``$model->delete()`` method on an instance of the model.
4343
- Chain methods to retrieve and delete an instance of a model by calling the
4444
``delete()`` method.
45-
- Call the ``Model::destroy($id)`` method on the model, passing it the id of
46-
the document to be deleted.
45+
- Call the ``Model::destroy($id)`` method on the model, passing it the
46+
``_id`` value of the document to be deleted.
4747

4848
delete() Method
4949
~~~~~~~~~~~~~~~
@@ -56,7 +56,6 @@ on an instance of the model:
5656
:dedent:
5757
:start-after: begin delete one model
5858
:end-before: end delete one model
59-
:caption: Delete the document by calling the delete() method on an instance.
6059

6160
When the ``delete()`` method succeeds, the operation returns the number of
6261
documents deleted.
@@ -72,34 +71,32 @@ matching document and delete it:
7271
:dedent:
7372
:start-after: begin model delete one fluent
7473
:end-before: end model delete one fluent
75-
:caption: Delete the matching document by chaining the delete() method.
7674

7775
.. include:: /includes/fact-orderby-id.rst
7876

7977
When the ``delete()`` method succeeds, it returns the number of documents
8078
deleted.
8179

8280
If the ``where()`` method does not match any documents, the ``delete()`` method
83-
returns returns ``0``.
81+
returns ``0``.
8482

8583
destroy() Method
8684
~~~~~~~~~~~~~~~~
8785

8886
The following example shows how to delete a document by passing the value of
89-
its id to the ``Model::destroy($id)`` method:
87+
its ``_id`` value to the ``Model::destroy($id)`` method:
9088

9189
.. literalinclude:: /includes/fundamentals/write-operations/WriteOperationsTest.php
9290
:language: php
9391
:dedent:
9492
:start-after: begin model delete by id
9593
:end-before: end model delete by id
96-
:caption: Delete the document by its id value.
9794

9895
When the ``destroy()`` method succeeds, it returns the number of documents
9996
deleted.
10097

101-
If the id value does not match any documents, the ``destroy()`` method
102-
returns returns ``0``.
98+
If the ``_id`` value does not match any documents, the ``destroy()`` method
99+
returns ``0``.
103100

104101
.. _laravel-fundamentals-delete-many:
105102

@@ -118,14 +115,13 @@ destroy() Method
118115
~~~~~~~~~~~~~~~~
119116

120117
The following example shows how to delete a document by passing an array of
121-
id values, represented by ``$ids``, to the ``destroy()`` method:
118+
``_id`` values, represented by ``$ids``, to the ``destroy()`` method:
122119

123120
.. literalinclude:: /includes/fundamentals/write-operations/WriteOperationsTest.php
124121
:language: php
125122
:dedent:
126123
:start-after: begin model delete multiple by id
127124
:end-before: end model delete multiple by id
128-
:caption: Delete documents by their ids.
129125

130126
.. tip::
131127

@@ -135,8 +131,8 @@ id values, represented by ``$ids``, to the ``destroy()`` method:
135131
When the ``destroy()`` method succeeds, it returns the number of documents
136132
deleted.
137133

138-
If the id values do not match any documents, the ``destroy()`` method
139-
returns returns ``0``.
134+
If the ``_id`` values do not match any documents, the ``destroy()`` method
135+
returns ``0``.
140136

141137
delete() Method
142138
~~~~~~~~~~~~~~~
@@ -149,7 +145,6 @@ and delete them:
149145
:dedent:
150146
:start-after: begin model delete multiple fluent
151147
:end-before: end model delete multiple fluent
152-
:caption: Chain calls to retrieve matching documents and delete them.
153148

154149
When the ``delete()`` method succeeds, it returns the number of documents
155150
deleted.

docs/fundamentals/write-operations/insert.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ This example code performs the following actions:
6868
:dedent:
6969
:start-after: begin model insert one
7070
:end-before: end model insert one
71-
:caption: Insert a document by calling the save() method on an instance.
7271

7372
You can retrieve the inserted document's ``_id`` value by accessing the model's
7473
``id`` member, as shown in the following code example:
@@ -106,21 +105,22 @@ to save the documents.
106105
When the ``insert()`` method succeeds, it returns the value ``1``. If it
107106
fails, it throws an exception.
108107

109-
The example code saves multiple models in a single call by passing them as
110-
an array to the ``insert()`` method:
111-
112-
.. note::
113-
114-
This example wraps the dates in the `MongoDB\\BSON\\UTCDateTime <{+phplib-api+}/class.mongodb-bson-utcdatetime.php>`__
115-
class to convert it to a type MongoDB can serialize because Laravel
116-
skips attribute casting on bulk insert operations.
108+
The following example saves multiple models in a single call by passing
109+
them as an array to the ``insert()`` method:
117110

118111
.. literalinclude:: /includes/fundamentals/write-operations/WriteOperationsTest.php
119112
:language: php
120113
:dedent:
121114
:start-after: begin model insert many
122115
:end-before: end model insert many
123116

117+
.. note::
118+
119+
This example wraps the dates in the `MongoDB\\BSON\\UTCDateTime
120+
<{+phplib-api+}/class.mongodb-bson-utcdatetime.php>`__
121+
class to convert it to a type MongoDB can serialize because Laravel
122+
skips attribute casting on bulk insert operations.
123+
124124
Additional Information
125125
----------------------
126126

docs/fundamentals/write-operations/modify.txt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ of the model and calling its ``save()`` method:
5959
:dedent:
6060
:start-after: begin model update one save
6161
:end-before: end model update one save
62-
:caption: Update a document by calling the save() method on an instance.
6362

6463
When the ``save()`` method succeeds, the model instance on which you called the
6564
method contains the updated values.
@@ -74,7 +73,6 @@ retrieve and update the first matching document:
7473
:dedent:
7574
:start-after: begin model update one fluent
7675
:end-before: end model update one fluent
77-
:caption: Update the matching document by chaining the update() method.
7876

7977
.. include:: /includes/fact-orderby-id.rst
8078

@@ -141,17 +139,16 @@ the following methods:
141139
Upsert Method
142140
~~~~~~~~~~~~~
143141

144-
The ``upsert(array $values, array|string $uniqueBy, array|null
145-
$update)`` method accepts the following parameters:
142+
The ``upsert()`` method accepts the following parameters:
146143

147144
- ``$values``: Array of fields and values that specify documents to update or insert.
148-
- ``$uniqueBy``: List of fields that uniquely identify documents in your
145+
- ``$uniqueBy``: One or more fields that uniquely identify documents in your
149146
first array parameter.
150-
- ``$update``: Optional list of fields to update if a matching document
147+
- ``$update``: Optional array of fields to update if a matching document
151148
exists. If you omit this parameter, the {+odm-short+} updates all fields.
152149

153-
To specify an upsert in the ``upsert()`` method, set parameters
154-
as shown in the following code example:
150+
To specify an upsert in the ``upsert()`` method, pass the required
151+
parameters as shown in the following code example:
155152

156153
.. code-block:: php
157154
:copyable: false
@@ -293,7 +290,7 @@ optional parameter ``unique`` to ``true`` to skip adding any duplicate values
293290
in the array. The following code example shows the structure of a ``push()``
294291
method call:
295292

296-
.. code-block:: none
293+
.. code-block:: php
297294
:copyable: false
298295

299296
YourModel::where(<match criteria>)
@@ -340,7 +337,7 @@ an array in a MongoDB document. You can pass one or more values to remove
340337
from the array. The following code example shows the structure of a
341338
``pull()`` method call:
342339

343-
.. code-block:: none
340+
.. code-block:: php
344341
:copyable: false
345342

346343
YourModel::where(<match criteria>)
@@ -387,7 +384,7 @@ structure of a positional operator update call on a single matching document:
387384
Currently, the {+odm-short+} offers this operation only on the ``DB`` facade
388385
and not on the Eloquent ORM.
389386

390-
.. code-block:: none
387+
.. code-block:: php
391388
:copyable: false
392389

393390
DB::connection('mongodb')
@@ -396,7 +393,6 @@ structure of a positional operator update call on a single matching document:
396393
<match criteria>,
397394
['$set' => ['<array field>.$' => <replacement value>]]);
398395

399-
400396
The following example shows how to replace the array value ``"dance-pop"``
401397
with ``"contemporary"`` in the ``genres`` array field. Click the
402398
:guilabel:`{+code-output-label+}` button to see the updated document:

0 commit comments

Comments
 (0)