Skip to content

Commit

Permalink
DOCSP-36792: Add default database connection admonition (#2888)
Browse files Browse the repository at this point in the history
Adds an admonition that advises users to set their default database connection to MongoDB
  • Loading branch information
norareidy authored Apr 24, 2024
1 parent 6ac2b6a commit 6c5dff2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/query-builder.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ The following example shows the syntax of a query builder call:
DB::collection('<collection name>')
// chain methods by using the "->" object operator
->get();
.. tip::

Before using the ``DB::collection()`` method, ensure that you specify MongoDB as your application's
default database connection. For instructions on setting the database connection,
see the :ref:`laravel-quick-start-connect-to-mongodb` step in the Quick Start.

If MongoDB is not your application's default database, you can use the ``DB::connection()`` method
to specify a MongoDB connection. Pass the name of the connection to the ``connection()`` method,
as shown in the following code:

.. code-block:: php

$connection = DB::connection('mongodb');

This guide provides examples of the following types of query builder operations:

Expand Down

0 comments on commit 6c5dff2

Please sign in to comment.