From 98474c34d90b6f08ff2107eaeb4b7488ae763681 Mon Sep 17 00:00:00 2001 From: Nora Reidy Date: Fri, 13 Sep 2024 11:33:33 -0400 Subject: [PATCH] DOCSP-43530: Id field in query results (#3149) Adds information about ID field representation in query builder results --- docs/query-builder.txt | 7 ++++--- docs/upgrade.txt | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/query-builder.txt b/docs/query-builder.txt index 0a4c878df..2bb6f75f2 100644 --- a/docs/query-builder.txt +++ b/docs/query-builder.txt @@ -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`` diff --git a/docs/upgrade.txt b/docs/upgrade.txt index 17d44cbb3..3032b8e1e 100644 --- a/docs/upgrade.txt +++ b/docs/upgrade.txt @@ -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