@@ -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`
@@ -647,6 +651,33 @@ value of ``imdb.rating`` of those matches by using the
647
651
:start-after: begin aggregation with filter
648
652
:end-before: end aggregation with filter
649
653
654
+ .. _laravel-options-query-builder:
655
+
656
+ Set Query-Level Options
657
+ -----------------------
658
+
659
+ You can modify the way that the {+odm-short+} performs operations by
660
+ setting options on the query builder. You can pass an array of options
661
+ to the ``options()`` query builder method to specify options for the
662
+ query.
663
+
664
+ The following code demonstrates how to attach a comment to
665
+ a query:
666
+
667
+ .. literalinclude:: /includes/query-builder/QueryBuilderTest.php
668
+ :language: php
669
+ :dedent:
670
+ :start-after: begin options
671
+ :end-before: end options
672
+
673
+ The query builder accepts the same options that you can set for
674
+ the :phpmethod:`find() <phpmethod.MongoDB\\Collection::find()>` method in the
675
+ {+php-library+}. Some of the options to modify query results, such as
676
+ ``skip``, ``sort``, and ``limit``, are settable directly as query
677
+ builder methods and are described in the
678
+ :ref:`laravel-modify-results-query-builder` section of this guide. We
679
+ recommend that you use these methods instead of passing them as options.
680
+
650
681
.. _laravel-modify-results-query-builder:
651
682
652
683
Modify Query Results
0 commit comments