@@ -46,15 +46,19 @@ 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
@@ -63,6 +67,7 @@ The following example shows the syntax of a query builder call:
6367This guide provides examples of the following types of query builder operations:
6468
6569- :ref:`laravel-retrieve-query-builder`
70+ - :ref:`laravel-options-query-builder`
6671- :ref:`laravel-modify-results-query-builder`
6772- :ref:`laravel-mongodb-read-query-builder`
6873- :ref:`laravel-mongodb-write-query-builder`
@@ -606,6 +611,33 @@ value of ``imdb.rating`` of those matches by using the
606611 :start-after: begin aggregation with filter
607612 :end-before: end aggregation with filter
608613
614+ .. _laravel-options-query-builder:
615+
616+ Set Query-Level Options
617+ -----------------------
618+
619+ You can modify the way that the {+odm-short+} performs operations by
620+ setting options on the query builder. You can pass an array of options
621+ to the ``options()`` query builder method to specify options for the
622+ query.
623+
624+ The following code demonstrates how to attach a comment to
625+ a query:
626+
627+ .. literalinclude:: /includes/query-builder/QueryBuilderTest.php
628+ :language: php
629+ :dedent:
630+ :start-after: begin options
631+ :end-before: end options
632+
633+ The query builder accepts the same options that you can set for
634+ the :phpmethod:`find() <phpmethod.MongoDB\\Collection::find()>` method in the
635+ {+php-library+}. Some of the options to modify query results, such as
636+ ``skip``, ``sort``, and ``limit``, are settable directly as query
637+ builder methods and are described in the
638+ :ref:`laravel-modify-results-query-builder` section of this guide. We
639+ recommend that you use these methods instead of passing them as options.
640+
609641.. _laravel-modify-results-query-builder:
610642
611643Modify Query Results
0 commit comments