File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ public function testOrWhere(): void
63
63
// begin query orWhere
64
64
$ result = DB ::connection ('mongodb ' )
65
65
->collection ('movies ' )
66
- ->where ('year ' , 1955 )
66
+ ->where ('id ' , new ObjectId ( ' 573a1398f29313caabce9682 ' ) )
67
67
->orWhere ('title ' , 'Back to the Future ' )
68
68
->get ();
69
69
// end query orWhere
Original file line number Diff line number Diff line change @@ -176,15 +176,24 @@ Logical OR Example
176
176
177
177
The following example shows how to chain the ``orWhere()``
178
178
query builder method to retrieve documents from the
179
- ``movies`` collection that either match the ``year``
180
- value of ``1955`` or match the ``title`` value ``"Back to the Future"``:
179
+ ``movies`` collection in which the value of the ``_id``
180
+ field is ``ObjectId('573a1398f29313caabce9682')`` or
181
+ the value of the ``title`` field is ``"Back to the Future"``:
181
182
182
183
.. literalinclude:: /includes/query-builder/QueryBuilderTest.php
183
184
:language: php
184
185
:dedent:
185
186
:start-after: begin query orWhere
186
187
:end-before: end query orWhere
187
188
189
+ .. note:: id Alias
190
+
191
+ Starting in v4.6, you can use the ``id`` alias in your queries to represent
192
+ the ``_id`` field in MongoDB documents, as shown in the preceding
193
+ code. When you run a find operation by using the query builder, {+odm-short+}
194
+ automatically converts between ``id`` and ``_id``. Because of this behavior,
195
+ you cannot have two separate ``id`` and ``_id`` fields in your documents.
196
+
188
197
.. _laravel-query-builder-logical-and:
189
198
190
199
Logical AND Example
You can’t perform that action at this time.
0 commit comments