Skip to content

Commit

Permalink
DOCSP-43530: Id field in query results (#3149)
Browse files Browse the repository at this point in the history
Adds information about ID field representation in query builder results
  • Loading branch information
norareidy authored Sep 13, 2024
1 parent cf9c9b1 commit 98474c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions docs/query-builder.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,10 @@ the value of the ``title`` field is ``"Back to the Future"``:

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``. This provides better
compatibility with Laravel, as the framework assumes that each record has a
code. When you use the query builder to run a find operation, the {+odm-short+}
automatically converts between ``_id`` and ``id`` field names. In query results,
the ``_id`` field is presented as ``id``. This provides better
consistency with Laravel, as the framework assumes that each record has a
primary key named ``id`` by default.

Because of this behavior, you cannot have two separate ``id`` and ``_id``
Expand Down
7 changes: 4 additions & 3 deletions docs/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ This library version introduces the following breaking changes:
date classes, applying the default timezone.

- ``id`` is an alias for the ``_id`` field in MongoDB documents, and the library
automatically converts between ``id`` and ``_id`` when querying data. Because
of this behavior, you cannot have two separate ``id`` and ``_id`` fields in your
documents.
automatically converts between ``id`` and ``_id`` when querying data. The query
result object includes an ``id`` field to represent the document's ``_id`` field.
Because of this behavior, you cannot have two separate ``id`` and ``_id`` fields
in your documents.

- Removes support for the ``$collection`` property. The following code shows
how to assign a MongoDB collection to a variable in your ``User`` class in
Expand Down

0 comments on commit 98474c3

Please sign in to comment.