Skip to content

Commit 6c274eb

Browse files
committed
feedback edits
1 parent 4943a55 commit 6c274eb

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

docs/includes/query-builder/QueryBuilderTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,13 @@ public function testWhereIn(): void
150150

151151
public function testWhereDate(): void
152152
{
153-
// begin query whereDate
153+
// begin query where date
154154
$result = DB::connection('mongodb')
155155
->table('movies')
156-
->whereDate('released', '2010-1-15')
157-
->get();
158-
// end query whereDate
156+
->where('released', new UTCDateTime(
157+
Carbon::create(2010, 1, 15, 0, 0, 0, 'UTC')
158+
))->get();
159+
// end query where date
159160

160161
$this->assertInstanceOf(\Illuminate\Support\Collection::class, $result);
161162
}

docs/query-builder.txt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,23 +348,26 @@ query builder method to retrieve documents from the
348348
Match Dates Example
349349
^^^^^^^^^^^^^^^^^^^
350350

351-
The following example shows how to use the ``whereDate()``
351+
The following example shows how to use the ``where()``
352352
query builder method to retrieve documents from the
353-
``movies`` collection that match the specified date of
354-
``2010-1-15`` in the ``released`` field:
353+
``movies`` collection in which the ``released`` value
354+
is ``2010, 1, 15, 0, 0, 0``, specified in a ``Carbon`` object:
355355

356356
.. literalinclude:: /includes/query-builder/QueryBuilderTest.php
357357
:language: php
358358
:dedent:
359-
:start-after: begin query whereDate
360-
:end-before: end query whereDate
359+
:start-after: begin query where date
360+
:end-before: end query where date
361361

362362
.. note:: Date Query Result Type
363363

364-
Starting in {+odm-long+} v5.0, ``UTCDateTime`` BSON values in MongoDB
365-
are returned as `Carbon <https://carbon.nesbot.com/docs/>`__ date
366-
classes in query results. The {+odm-short+} applies the default
367-
timezone when performing this conversion.
364+
Starting in {+odm-long+} v5.0, `Carbon <https://carbon.nesbot.com/docs/>`__
365+
objects passed as query filters, as shown in the preceding code example, are
366+
converted to ``UTCDateTime`` BSON values.
367+
368+
In query results, ``UTCDateTime`` BSON values in MongoDB are returned as ``Carbon``
369+
objects. The {+odm-short+} applies the default timezone when performing
370+
this conversion.
368371

369372
.. _laravel-query-builder-pattern:
370373

docs/upgrade.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ This library version introduces the following breaking changes:
8181
use the default ``Illuminate\Queue\Failed\DatabaseFailedJobProvider``
8282
class and specify a connection to MongoDB.
8383

84+
- When using a ``DateTimeInterface`` object, including ``Carbon``, in a query,
85+
the library converts the ``DateTimeInterface`` to a ``MongoDB\BSON\UTCDateTime``
86+
object. This conversion applies to ``DateTimeInterface`` objects passed as query
87+
filters to the ``where()`` method or as data passed to the ``insert()`` and
88+
``update()`` methods. For an example that passes a ``Carbon`` object to the
89+
``DB::where()`` method, see the :ref:`laravel-query-builder-wheredate`
90+
section of the Query Builder guide.
91+
8492
- In query results, the library converts BSON ``UTCDateTime`` objects to ``Carbon``
8593
date classes, applying the default timezone.
8694

@@ -89,9 +97,6 @@ This library version introduces the following breaking changes:
8997
of this behavior, you cannot have two separate ``id`` and ``_id`` fields in your
9098
documents.
9199

92-
- When using a ``DateTimeInterface`` object in a query, the library converts
93-
the ``DateTimeInterface`` to a ``MongoDB\BSON\UTCDateTime`` object.
94-
95100
.. _laravel-breaking-changes-v4.x:
96101

97102
Version 4.x Breaking Changes

0 commit comments

Comments
 (0)