Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/includes/query-builder/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Database\Query\Builder;
use Illuminate\Pagination\AbstractPaginator;
use Illuminate\Support\Facades\DB;
use MongoDB\BSON\ObjectId;
use MongoDB\BSON\Regex;
use MongoDB\Laravel\Collection;
use MongoDB\Laravel\Tests\TestCase;
Expand Down Expand Up @@ -63,7 +64,7 @@ public function testOrWhere(): void
// begin query orWhere
$result = DB::connection('mongodb')
->collection('movies')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
->collection('movies')
->table('movies')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make the rest of these collection -> table changes in https://jira.mongodb.org/browse/DOCSP-42956

->where('year', 1955)
->where('id', new ObjectId('573a1398f29313caabce9682'))
->orWhere('title', 'Back to the Future')
->get();
// end query orWhere
Expand Down
13 changes: 11 additions & 2 deletions docs/query-builder.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,24 @@ Logical OR Example

The following example shows how to chain the ``orWhere()``
query builder method to retrieve documents from the
``movies`` collection that either match the ``year``
value of ``1955`` or match the ``title`` value ``"Back to the Future"``:
``movies`` collection that either match the ``_id``
value of ``ObjectId('573a1398f29313caabce9682')`` or match
the ``title`` value ``"Back to the Future"``:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``movies`` collection that either match the ``_id``
value of ``ObjectId('573a1398f29313caabce9682')`` or match
the ``title`` value ``"Back to the Future"``:
``movies`` collection in which the value of the``_id``
field is ``ObjectId('573a1398f29313caabce9682')`` or
the value of the ``title`` field is ``"Back to the Future"``:


.. literalinclude:: /includes/query-builder/QueryBuilderTest.php
:language: php
:dedent:
:start-after: begin query orWhere
:end-before: end query orWhere

.. note::

Beginning in {+odm-short+} v5.0, you can use the ``id`` alias to
represent the ``_id`` field, as shown in the preceding code. When you
run a find operation using the query builder, {+odm-short+}
automatically converts between ``id`` and ``_id``. You cannot have
two separate ``id`` and ``_id`` fields in your documents.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S: (applies when you change the target branch to 5.0) Remove versioning since this is only going to be in that version of docs anyways

Suggested change
.. note::
Beginning in {+odm-short+} v5.0, you can use the ``id`` alias to
represent the ``_id`` field, as shown in the preceding code. When you
run a find operation using the query builder, {+odm-short+}
automatically converts between ``id`` and ``_id``. You cannot have
two separate ``id`` and ``_id`` fields in your documents.
.. note::
You can use the ``id`` alias in your queries to
represent the ``_id`` field in MongoDB documents, as shown in the preceding code. When you
run a find operation using the query builder, {+odm-short+}
automatically converts between ``id`` and ``_id``. Because of this behavior,
you cannot have two separate ``id`` and ``_id`` fields in your documents.


.. _laravel-query-builder-logical-and:

Logical AND Example
Expand Down