You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+26-2Lines changed: 26 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,34 @@
1
1
# Changelog
2
2
All notable changes to this project will be documented in this file.
3
3
4
-
## [4.9.0] - coming soon
4
+
## [5.0.0] - next
5
5
6
+
***BREAKING CHANGE** Use `id` as an alias for `_id` in commands and queries for compatibility with Eloquent packages by @GromNaN in [#3040](https://github.com/mongodb/laravel-mongodb/pull/3040)
7
+
***BREAKING CHANGE** Make Query\Builder return objects instead of array to match Laravel behavior by @GromNaN in [#3107](https://github.com/mongodb/laravel-mongodb/pull/3107)
8
+
9
+
## [4.8.0] - 2024-08-27
10
+
11
+
* Add `Query\Builder::incrementEach()` and `decrementEach()` methods by @SmallRuralDog in [#2550](https://github.com/mongodb/laravel-mongodb/pull/2550)
12
+
* Add `Query\Builder::whereLike()` and `whereNotLike()` methods by @GromNaN in [#3108](https://github.com/mongodb/laravel-mongodb/pull/3108)
13
+
* Deprecate `Connection::collection()` and `Schema\Builder::collection()` methods by @GromNaN in [#3062](https://github.com/mongodb/laravel-mongodb/pull/3062)
14
+
* Deprecate `Model::$collection` property to customize collection name. Use `$table` instead by @GromNaN in [#3064](https://github.com/mongodb/laravel-mongodb/pull/3064)
15
+
16
+
## [4.7.2] - 2024-08-27
17
+
18
+
* Add `Query\Builder::upsert()` method with a single document by @GromNaN in [#3100](https://github.com/mongodb/laravel-mongodb/pull/3100)
19
+
20
+
## [4.7.1] - 2024-07-25
21
+
22
+
* Fix registration of `BusServiceProvider` for compatibility with Horizon by @GromNaN in [#3071](https://github.com/mongodb/laravel-mongodb/pull/3071)
23
+
24
+
## [4.7.0] - 2024-07-19
25
+
26
+
* Add `Query\Builder::upsert()` method by @GromNaN in [#3052](https://github.com/mongodb/laravel-mongodb/pull/3052)
6
27
* Add `Connection::getServerVersion()` by @GromNaN in [#3043](https://github.com/mongodb/laravel-mongodb/pull/3043)
7
-
* Add `Schema\Builder::getTables()` and `getTableListing` by @GromNaN in [#3044](https://github.com/mongodb/laravel-mongodb/pull/3044)
28
+
* Add `Schema\Builder::getTables()` and `getTableListing()` by @GromNaN in [#3044](https://github.com/mongodb/laravel-mongodb/pull/3044)
29
+
* Add `Schema\Builder::getColumns()` and `getIndexes()` by @GromNaN in [#3045](https://github.com/mongodb/laravel-mongodb/pull/3045)
30
+
* Add `Schema\Builder::hasColumn()` and `hasColumns()` method by @Alex-Belyi in [#3001](https://github.com/mongodb/laravel-mongodb/pull/3001)
31
+
* Fix unsetting a field in an embedded model by @GromNaN in [#3052](https://github.com/mongodb/laravel-mongodb/pull/3052)
@@ -107,7 +111,7 @@ Change the Model Collection Name
107
111
108
112
By default, the model uses the snake case plural form of your model
109
113
class name. To change the name of the collection the model uses to retrieve
110
-
and save data in MongoDB, override the ``$collection`` property of the model
114
+
and save data in MongoDB, override the ``$table`` property of the model
111
115
class.
112
116
113
117
.. note::
@@ -123,7 +127,7 @@ The following example specifies the custom MongoDB collection name,
123
127
:emphasize-lines: 9
124
128
:dedent:
125
129
126
-
Without overriding the ``$collection`` property, this model maps to the
130
+
Without overriding the ``$table`` property, this model maps to the
127
131
``planets`` collection. With the overridden property, the example class stores
128
132
the model in the ``celestial_body`` collection.
129
133
@@ -151,7 +155,7 @@ To learn more about primary key behavior and customization options, see
151
155
in the Laravel docs.
152
156
153
157
To learn more about the ``_id`` field, ObjectIDs, and the MongoDB document
154
-
structure, see :manual:`Documents </core/document>` in the MongoDB server docs.
158
+
structure, see :manual:`Documents </core/document>` in the Server manual.
155
159
156
160
.. _laravel-model-soft-delete:
157
161
@@ -179,7 +183,7 @@ in the Laravel docs.
179
183
.. _laravel-model-cast-data-types:
180
184
181
185
Cast Data Types
182
-
---------------
186
+
~~~~~~~~~~~~~~~
183
187
184
188
Eloquent lets you convert model attribute data types before storing or
185
189
retrieving data by using a casting helper. This helper is a convenient
@@ -223,7 +227,7 @@ less than three years ago:
223
227
Planet::where( 'discovery_dt', '>', new DateTime('-3 years'))->get();
224
228
225
229
To learn more about MongoDB's data types, see :manual:`BSON Types </reference/bson-types/>`
226
-
in the MongoDB server docs.
230
+
in the Server manual.
227
231
228
232
To learn more about the Laravel casting helper and supported types, see `Attribute Casting <https://laravel.com/docs/{+laravel-docs-version+}/eloquent-mutators#attribute-casting>`__
229
233
in the Laravel docs.
@@ -280,6 +284,45 @@ To learn how to change the behavior when attempting to fill a field omitted
280
284
from the ``$fillable`` array, see `Mass Assignment Exceptions <https://laravel.com/docs/{+laravel-docs-version+}/eloquent#mass-assignment-exceptions>`__
281
285
in the Laravel docs.
282
286
287
+
.. _laravel-third-party-model:
288
+
289
+
Extend Third-Party Model Classes
290
+
--------------------------------
291
+
292
+
You can use the {+odm-short+} to extend a third-party model class by
293
+
including the ``DocumentModel`` trait when defining your model class. By
294
+
including this trait, you can make the third-party class compatible with
295
+
MongoDB.
296
+
297
+
When you apply the ``DocumentModel`` trait to a model class, you must
298
+
declare the following properties in your class:
299
+
300
+
- ``$primaryKey = '_id'``, because the ``_id`` field uniquely
301
+
identifies MongoDB documents
302
+
- ``$keyType = 'string'``, because the {+odm-short+} casts MongoDB
303
+
``ObjectId`` values to type ``string``
304
+
305
+
Extended Class Example
306
+
~~~~~~~~~~~~~~~~~~~~~~
307
+
308
+
This example creates a ``Planet`` model class that extends the
309
+
``CelestialBody`` class from a package called ``ThirdPartyPackage``. The
310
+
``Post`` class includes the ``DocumentModel`` trait and defines
311
+
properties including ``$primaryKey`` and ``$keyType``:
0 commit comments