Skip to content

Commit e558e60

Browse files
committed
formatting
1 parent 79035d5 commit e558e60

File tree

5 files changed

+36
-104
lines changed

5 files changed

+36
-104
lines changed

docs/includes/usage-examples/FindOneTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ public function testFindOne(): void
4343
// end-qb-find-one
4444

4545
$this->assertSame($movie['title'], 'The Shawshank Redemption');
46+
$this->expectOutputString('{"_id":"679cdb4834e26dc5370de462","title":"The Shawshank Redemption","directors":["Frank Darabont","Rob Reiner"]}The Shawshank Redemption');
4647
}
4748
}

docs/includes/usage-examples/InsertOneTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ public function testInsertOne(): void
4343

4444
$this->assertInstanceOf(Movie::class, $movie);
4545
$this->assertSame($movie->title, 'Marriage Story');
46+
$this->expectOutputString('{"title":"Marriage Story","year":2019,"runtime":136,"updated_at":"2025-01-31T14:16:40.834000Z","created_at":"2025-01-31T14:16:40.834000Z","_id":"679cdb488f9fa3d481091a42"}Insert operation success: yes');
4647
}
4748
}

docs/includes/usage-examples/UpdateOneTest.php

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace App\Http\Controllers;
66

77
use App\Models\Movie;
8-
use Illuminate\Support\Facades\DB;
98
use MongoDB\Laravel\Tests\TestCase;
109

1110
class UpdateOneTest extends TestCase
@@ -44,24 +43,6 @@ public function testUpdateOne(): void
4443
// end-eloquent-update-one
4544

4645
$this->assertTrue($updates);
47-
48-
// begin-qb-update-one
49-
$updates = DB::table('movies')
50-
->updateOne(
51-
['title' => 'Carol'],
52-
[
53-
'$set' => [
54-
'imdb' => [
55-
'rating' => 7.3,
56-
'votes' => 142000,
57-
],
58-
],
59-
],
60-
);
61-
62-
echo 'Updated documents: ' . $updates;
63-
// end-qb-update-one
64-
65-
$this->expectOutputString('Updated documents: 1Updated documents: 0');
46+
$this->expectOutputString('Updated documents: 1');
6647
}
6748
}

docs/usage-examples/findOne.txt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ each corresponding query syntax:
8989
method from the ``DB`` facade
9090
- Retrieves a document from the ``movies`` collection that matches
9191
a query filter
92-
- Prints the retrieved document
92+
- Prints the ``title`` field of the retrieved document
9393

9494
The example calls the following query builder methods:
9595

@@ -110,13 +110,6 @@ each corresponding query syntax:
110110
:language: console
111111
:visible: false
112112

113-
// Result is truncated
114-
115-
{
116-
"_id": ...,
117-
"title": "This Is Spinal Tap",
118-
"directors": [ "Rob Reiner" ],
119-
...
120-
}
113+
This Is Spinal Tap
121114

122115
.. include:: /includes/usage-examples/fact-edit-laravel-app.rst

docs/usage-examples/updateOne.txt

Lines changed: 31 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -32,81 +32,37 @@ by passing your intended document changes to the ``update()`` method.
3232
Example
3333
-------
3434

35-
Select from the following :guilabel:`Eloquent` and :guilabel:`Query
36-
Builder` tabs to view usage examples for the same operation that use
37-
each corresponding query syntax:
38-
39-
.. tabs::
40-
41-
.. tab:: Eloquent
42-
:tabid: eloquent-model-count
43-
44-
This example performs the following actions:
45-
46-
- Uses the ``Movie`` Eloquent model to represent the ``movies``
47-
collection in the ``sample_mflix`` database
48-
- Updates a document from the ``movies`` collection that matches
49-
the query filter
50-
- Prints the number of updated documents
51-
52-
The example calls the following methods on the ``Movie`` model:
53-
54-
- ``where()``: Matches documents in which the value of the
55-
``title`` field is ``"Carol"``
56-
- ``orderBy()``: Sorts matched documents by their ascending ``_id`` values
57-
- ``first()``: Retrieves only the first matching document.
58-
- ``update()``: Updates the value of the ``imdb.rating`` nested
59-
field to from ``6.9`` to ``7.3`` and the value of the
60-
``imdb.votes`` nested field from ``493`` to ``142000``
61-
62-
.. io-code-block::
63-
:copyable: true
64-
65-
.. input:: ../includes/usage-examples/UpdateOneTest.php
66-
:start-after: begin-eloquent-update-one
67-
:end-before: end-eloquent-update-one
68-
:language: php
69-
:dedent:
70-
71-
.. output::
72-
:language: console
73-
:visible: false
35+
This example performs the following actions:
7436

75-
Updated documents: 1
76-
77-
.. tab:: Query Builder
78-
:tabid: query-builder-count
79-
80-
This example performs the following actions:
81-
82-
- Accesses the ``movies`` collection by calling the ``table()``
83-
method from the ``DB`` facade
84-
- Updates a document from the ``movies`` collection that matches
85-
the query filter
86-
- Prints the number of updated documents
87-
88-
The example calls the following query builder methods:
89-
90-
- ``where()``: Matches documents in which the value of the
91-
``title`` field is ``"Carol"``
92-
- ``orderBy()``: Sorts matched documents by their ascending ``_id`` values
93-
- ``first()``: Retrieves only the first matching document.
94-
- ``update()``: Updates the value of the ``imdb.rating`` nested
95-
field to from ``6.9`` to ``7.3`` and the value of the
96-
``imdb.votes`` nested field from ``493`` to ``142000``
97-
98-
.. io-code-block::
99-
100-
.. input:: ../includes/usage-examples/UpdateOneTest.php
101-
:start-after: begin-qb-update-one
102-
:end-before: end-qb-update-one
103-
:language: php
104-
:dedent:
105-
106-
.. output::
107-
:language: console
108-
:visible: false
109-
110-
Updated documents: 1
37+
- Uses the ``Movie`` Eloquent model to represent the ``movies``
38+
collection in the ``sample_mflix`` database
39+
- Updates a document from the ``movies`` collection that matches
40+
the query filter
41+
- Prints the number of updated documents
42+
43+
The example calls the following methods on the ``Movie`` model:
44+
45+
- ``where()``: Matches documents in which the value of the
46+
``title`` field is ``"Carol"``
47+
- ``orderBy()``: Sorts matched documents by their ascending ``_id`` values
48+
- ``first()``: Retrieves only the first matching document.
49+
- ``update()``: Updates the value of the ``imdb.rating`` nested
50+
field to from ``6.9`` to ``7.3`` and the value of the
51+
``imdb.votes`` nested field from ``493`` to ``142000``
52+
53+
.. io-code-block::
54+
:copyable: true
55+
56+
.. input:: ../includes/usage-examples/UpdateOneTest.php
57+
:start-after: begin-eloquent-update-one
58+
:end-before: end-eloquent-update-one
59+
:language: php
60+
:dedent:
61+
62+
.. output::
63+
:language: console
64+
:visible: false
65+
66+
Updated documents: 1
11167

11268
.. include:: /includes/usage-examples/fact-edit-laravel-app.rst

0 commit comments

Comments
 (0)