From c038ed8fdb555ff0fd17bd4e325ff672d38a348b Mon Sep 17 00:00:00 2001 From: rustagir Date: Tue, 19 Nov 2024 11:20:07 -0500 Subject: [PATCH 1/3] DOCSP-45411: qb options --- .../query-builder/QueryBuilderTest.php | 13 ++++++ docs/query-builder.txt | 44 ++++++++++++++++--- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/docs/includes/query-builder/QueryBuilderTest.php b/docs/includes/query-builder/QueryBuilderTest.php index 46822f257..229db2867 100644 --- a/docs/includes/query-builder/QueryBuilderTest.php +++ b/docs/includes/query-builder/QueryBuilderTest.php @@ -46,6 +46,19 @@ protected function tearDown(): void parent::tearDown(); } + public function testOptions(): void + { + // begin options + $result = DB::connection('mongodb') + ->table('movies') + ->where('year', 2000) + ->options(['comment' => 'hello']) + ->get(); + // end options + + $this->assertInstanceOf(\Illuminate\Support\Collection::class, $result); + } + public function testWhere(): void { // begin query where diff --git a/docs/query-builder.txt b/docs/query-builder.txt index 7d33c016d..88ea5dc75 100644 --- a/docs/query-builder.txt +++ b/docs/query-builder.txt @@ -46,15 +46,19 @@ The following example shows the syntax of a query builder call: DB::table('') // chain methods by using the "->" object operator ->get(); + .. tip:: - Before using the ``DB::table()`` method, ensure that you specify MongoDB as your application's - default database connection. For instructions on setting the database connection, - see the :ref:`laravel-quick-start-connect-to-mongodb` step in the Quick Start. + Before using the ``DB::table()`` method, ensure that you specify + MongoDB as your application's default database connection. For + instructions on setting the database connection, see the + :ref:`laravel-quick-start-connect-to-mongodb` step in the Quick + Start. - If MongoDB is not your application's default database, you can use the ``DB::connection()`` method - to specify a MongoDB connection. Pass the name of the connection to the ``connection()`` method, - as shown in the following code: + If MongoDB is not your application's default database, you can use + the ``DB::connection()`` method to specify a MongoDB connection. Pass + the name of the connection to the ``connection()`` method, as shown + in the following code: .. code-block:: php @@ -62,6 +66,7 @@ The following example shows the syntax of a query builder call: This guide provides examples of the following types of query builder operations: +- :ref:`laravel-options-query-builder` - :ref:`laravel-retrieve-query-builder` - :ref:`laravel-modify-results-query-builder` - :ref:`laravel-mongodb-read-query-builder` @@ -81,6 +86,33 @@ of the Quick Start. To perform read and write operations by using the query builder, import the ``Illuminate\Support\Facades\DB`` facade and compose your query. +.. _laravel-options-query-builder: + +Set Query-Level Options +----------------------- + +You can modify the way that the {+odm-short+} performs queries by +setting options on the query builder. You can pass an array of options +to the ``options()`` query builder method to specify options for the +query. + +The following code demonstrates how to attach a comment to +a query: + +.. literalinclude:: /includes/query-builder/QueryBuilderTest.php + :language: php + :dedent: + :start-after: begin options + :end-before: end options + +The query builder accepts the same options that you can set for +the :phpmethod:`MongoDB\Collection::find()` method in the +{+php-library+}. Some of the options to modify query results, such as +``skip``, ``sort``, and ``limit``, are settable directly as query +builder methods and are described in the +:ref:`laravel-modify-results-query-builder` section of this guide. We +recommend that you use these methods instead of passing them as options. + .. _laravel-retrieve-query-builder: Retrieve Matching Documents From 91c1bf6075947633a10f0a1cfdd4e76267d13a30 Mon Sep 17 00:00:00 2001 From: rustagir Date: Tue, 19 Nov 2024 11:57:34 -0500 Subject: [PATCH 2/3] link --- docs/query-builder.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/query-builder.txt b/docs/query-builder.txt index 88ea5dc75..a00eddeea 100644 --- a/docs/query-builder.txt +++ b/docs/query-builder.txt @@ -106,7 +106,7 @@ a query: :end-before: end options The query builder accepts the same options that you can set for -the :phpmethod:`MongoDB\Collection::find()` method in the +the :phpmethod:`find() ` method in the {+php-library+}. Some of the options to modify query results, such as ``skip``, ``sort``, and ``limit``, are settable directly as query builder methods and are described in the From 84bad6d73dbc34ab766e466435bbd835785e684e Mon Sep 17 00:00:00 2001 From: rustagir Date: Tue, 19 Nov 2024 13:53:25 -0500 Subject: [PATCH 3/3] NR PR fixes 1 --- docs/query-builder.txt | 56 +++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/docs/query-builder.txt b/docs/query-builder.txt index a00eddeea..649cdde34 100644 --- a/docs/query-builder.txt +++ b/docs/query-builder.txt @@ -66,8 +66,8 @@ The following example shows the syntax of a query builder call: This guide provides examples of the following types of query builder operations: -- :ref:`laravel-options-query-builder` - :ref:`laravel-retrieve-query-builder` +- :ref:`laravel-options-query-builder` - :ref:`laravel-modify-results-query-builder` - :ref:`laravel-mongodb-read-query-builder` - :ref:`laravel-mongodb-write-query-builder` @@ -86,33 +86,6 @@ of the Quick Start. To perform read and write operations by using the query builder, import the ``Illuminate\Support\Facades\DB`` facade and compose your query. -.. _laravel-options-query-builder: - -Set Query-Level Options ------------------------ - -You can modify the way that the {+odm-short+} performs queries by -setting options on the query builder. You can pass an array of options -to the ``options()`` query builder method to specify options for the -query. - -The following code demonstrates how to attach a comment to -a query: - -.. literalinclude:: /includes/query-builder/QueryBuilderTest.php - :language: php - :dedent: - :start-after: begin options - :end-before: end options - -The query builder accepts the same options that you can set for -the :phpmethod:`find() ` method in the -{+php-library+}. Some of the options to modify query results, such as -``skip``, ``sort``, and ``limit``, are settable directly as query -builder methods and are described in the -:ref:`laravel-modify-results-query-builder` section of this guide. We -recommend that you use these methods instead of passing them as options. - .. _laravel-retrieve-query-builder: Retrieve Matching Documents @@ -638,6 +611,33 @@ value of ``imdb.rating`` of those matches by using the :start-after: begin aggregation with filter :end-before: end aggregation with filter +.. _laravel-options-query-builder: + +Set Query-Level Options +----------------------- + +You can modify the way that the {+odm-short+} performs operations by +setting options on the query builder. You can pass an array of options +to the ``options()`` query builder method to specify options for the +query. + +The following code demonstrates how to attach a comment to +a query: + +.. literalinclude:: /includes/query-builder/QueryBuilderTest.php + :language: php + :dedent: + :start-after: begin options + :end-before: end options + +The query builder accepts the same options that you can set for +the :phpmethod:`find() ` method in the +{+php-library+}. Some of the options to modify query results, such as +``skip``, ``sort``, and ``limit``, are settable directly as query +builder methods and are described in the +:ref:`laravel-modify-results-query-builder` section of this guide. We +recommend that you use these methods instead of passing them as options. + .. _laravel-modify-results-query-builder: Modify Query Results