Skip to content

Commit

Permalink
JT tech review 2
Browse files Browse the repository at this point in the history
  • Loading branch information
rustagir committed Sep 9, 2024
1 parent e1927ee commit faffb66
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/query-builder.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Chain methods to specify commands and any constraints. Then, chain
the ``get()`` method at the end to run the methods and retrieve the
results. To retrieve only the first matching result, chain the
``first()`` method instead of the ``get()`` method. Starting in
{+odm-long+} v5.0, the query builder returns results as objects.
{+odm-long+} v5.0, the query builder returns results as ``stdClass`` objects.

The following example shows the syntax of a query builder call:

Expand Down
21 changes: 13 additions & 8 deletions docs/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,25 @@ Version 5.x Breaking Changes

This library version introduces the following breaking changes:

- The query builder returns results as objects, instead of as arrays.
This change requires that you change array access to property access
when interacting with query results.
- The query builder returns results as as ``stdClass`` objects, instead
of as arrays. This change requires that you change array access to
property access when interacting with query results.

The following code shows how to retrieve a query result and access a
property from the result object:
property from the result object in older versions compared to v5.0:

.. code-block:: php
:emphasize-lines: 4
:emphasize-lines: 8

DB::table('accounts')
$document = DB::table('accounts')
->where('name', 'Anita Charles')
->first()
->balance
->first();

// older versions
$document['balance'];

// v5.0
$document->balance;

- In query results, the library converts BSON ``UTCDateTime`` objects to ``Carbon``
date classes, applying the default timezone.
Expand Down

0 comments on commit faffb66

Please sign in to comment.