@@ -46,22 +46,27 @@ The following example shows the syntax of a query builder call:
4646 DB::table('<collection name>')
4747 // chain methods by using the "->" object operator
4848 ->get();
49+
4950.. tip::
5051
51- Before using the ``DB::table()`` 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.
52+ Before using the ``DB::table()`` method, ensure that you specify
53+ MongoDB as your application's default database connection. For
54+ instructions on setting the database connection, see the
55+ :ref:`laravel-quick-start-connect-to-mongodb` step in the Quick
56+ Start.
5457
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+ If MongoDB is not your application's default database, you can use
59+ the ``DB::connection()`` method to specify a MongoDB connection. Pass
60+ the name of the connection to the ``connection()`` method, as shown
61+ in the following code:
5862
5963 .. code-block:: php
6064
6165 $connection = DB::connection('mongodb');
6266
6367This guide provides examples of the following types of query builder operations:
6468
69+ - :ref:`laravel-options-query-builder`
6570- :ref:`laravel-retrieve-query-builder`
6671- :ref:`laravel-modify-results-query-builder`
6772- :ref:`laravel-mongodb-read-query-builder`
@@ -81,6 +86,33 @@ of the Quick Start.
8186To perform read and write operations by using the query builder, import the
8287``Illuminate\Support\Facades\DB`` facade and compose your query.
8388
89+ .. _laravel-options-query-builder:
90+
91+ Set Query-Level Options
92+ -----------------------
93+
94+ You can modify the way that the {+odm-short+} performs queries by
95+ setting options on the query builder. You can pass an array of options
96+ to the ``options()`` query builder method to specify options for the
97+ query.
98+
99+ The following code demonstrates how to attach a comment to
100+ a query:
101+
102+ .. literalinclude:: /includes/query-builder/QueryBuilderTest.php
103+ :language: php
104+ :dedent:
105+ :start-after: begin options
106+ :end-before: end options
107+
108+ The query builder accepts the same options that you can set for
109+ the :phpmethod:`MongoDB\Collection::find()` method in the
110+ {+php-library+}. Some of the options to modify query results, such as
111+ ``skip``, ``sort``, and ``limit``, are settable directly as query
112+ builder methods and are described in the
113+ :ref:`laravel-modify-results-query-builder` section of this guide. We
114+ recommend that you use these methods instead of passing them as options.
115+
84116.. _laravel-retrieve-query-builder:
85117
86118Retrieve Matching Documents
0 commit comments