File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,19 @@ The following example shows the syntax of a query builder call:
4646 DB::collection('<collection name>')
4747 // chain methods by using the "->" object operator
4848 ->get();
49+ .. tip::
50+
51+ Before using the ``DB::collection()`` method, ensure that you specify MongoDB as your application's
52+ default database connection. For instructions on setting the database connection,
53+ see the :ref:`laravel-quick-start-connect-to-mongodb` step in the Quick Start.
54+
55+ If MongoDB is not your application's default database, you can use the ``DB::connection()`` method
56+ to specify a MongoDB connection. Pass the name of the connection to the ``connection()`` method,
57+ as shown in the following code:
58+
59+ .. code-block:: php
60+
61+ $connection = DB::connection('mongodb');
4962
5063This guide provides examples of the following types of query builder operations:
5164
You can’t perform that action at this time.
0 commit comments