Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPORM-219 Deprecate Connection::collection() and Schema::collection() #3062

Merged
merged 4 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
## [4.8.0] - next

* Add `Query\Builder::incrementEach()` and `decrementEach()` methods by @SmallRuralDog in [#2550](https://github.com/mongodb/laravel-mongodb/pull/2550)
* Deprecate `Connection::collection()` and `Schema\Builder::collection()` methods by @GromNaN in [#3062](https://github.com/mongodb/laravel-mongodb/pull/3062)

## [4.7.0] - 2024-07-19

Expand Down
18 changes: 12 additions & 6 deletions docs/fundamentals/database-collection.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ create a database connection to the ``animals`` database in the

.. code-block:: php
:emphasize-lines: 1,8

'default' => 'mongodb',

'connections' => [
Expand All @@ -77,7 +77,7 @@ The following example shows how to specify multiple database connections
``plants`` databases:

.. code-block:: php

'connections' => [

'mongodb' => [
Expand Down Expand Up @@ -145,23 +145,29 @@ Laravel retrieves results from the ``flowers`` collection:

Flower::where('name', 'Water Lily')->get()

.. note::

Starting in {+odm-short+} v4.8, the ``DB::collection()`` method
is deprecated. As shown in the following example, you can use the ``DB::table()``
method to access a MongoDB collection.

If you are unable to accomplish your operation by using an Eloquent
model, you can access the query builder by calling the ``collection()``
model, you can access the query builder by calling the ``table()``
method on the ``DB`` facade. The following example shows the same query
as in the preceding example, but the query is constructed by using the
``DB::collection()`` method:
``DB::table()`` method:

.. code-block:: php

DB::connection('mongodb')
->collection('flowers')
->table('flowers')
->where('name', 'Water Lily')
->get()

List Collections
----------------

To see information about each of the collections in a database, call the
To see information about each of the collections in a database, call the
``listCollections()`` method.

The following example accesses a database connection, then
Expand Down
Loading
Loading