@@ -53,13 +53,16 @@ The following example shows the syntax of a query builder call:
53
53
54
54
.. tip:: Set Database Connection
55
55
56
- Before using the ``DB::table()`` method, ensure that you specify MongoDB as your application's
57
- default database connection. For instructions on setting the database connection,
58
- see the :ref:`laravel-quick-start-connect-to-mongodb` step in the Quick Start.
56
+ Before using the ``DB::table()`` method, ensure that you specify
57
+ MongoDB as your application's default database connection. For
58
+ instructions on setting the database connection, see the
59
+ :ref:`laravel-quick-start-connect-to-mongodb` step in the Quick
60
+ Start.
59
61
60
- If MongoDB is not your application's default database, you can use the ``DB::connection()`` method
61
- to specify a MongoDB connection. Pass the name of the connection to the ``connection()`` method,
62
- as shown in the following code:
62
+ If MongoDB is not your application's default database, you can use
63
+ the ``DB::connection()`` method to specify a MongoDB connection. Pass
64
+ the name of the connection to the ``connection()`` method, as shown
65
+ in the following code:
63
66
64
67
.. code-block:: php
65
68
@@ -68,6 +71,7 @@ The following example shows the syntax of a query builder call:
68
71
This guide provides examples of the following types of query builder operations:
69
72
70
73
- :ref:`laravel-retrieve-query-builder`
74
+ - :ref:`laravel-options-query-builder`
71
75
- :ref:`laravel-modify-results-query-builder`
72
76
- :ref:`laravel-mongodb-read-query-builder`
73
77
- :ref:`laravel-mongodb-write-query-builder`
@@ -654,6 +658,33 @@ value of ``imdb.rating`` of those matches by using the
654
658
:start-after: begin aggregation with filter
655
659
:end-before: end aggregation with filter
656
660
661
+ .. _laravel-options-query-builder:
662
+
663
+ Set Query-Level Options
664
+ -----------------------
665
+
666
+ You can modify the way that the {+odm-short+} performs operations by
667
+ setting options on the query builder. You can pass an array of options
668
+ to the ``options()`` query builder method to specify options for the
669
+ query.
670
+
671
+ The following code demonstrates how to attach a comment to
672
+ a query:
673
+
674
+ .. literalinclude:: /includes/query-builder/QueryBuilderTest.php
675
+ :language: php
676
+ :dedent:
677
+ :start-after: begin options
678
+ :end-before: end options
679
+
680
+ The query builder accepts the same options that you can set for
681
+ the :phpmethod:`find() <phpmethod.MongoDB\\Collection::find()>` method in the
682
+ {+php-library+}. Some of the options to modify query results, such as
683
+ ``skip``, ``sort``, and ``limit``, are settable directly as query
684
+ builder methods and are described in the
685
+ :ref:`laravel-modify-results-query-builder` section of this guide. We
686
+ recommend that you use these methods instead of passing them as options.
687
+
657
688
.. _laravel-modify-results-query-builder:
658
689
659
690
Modify Query Results
0 commit comments